The Page Flow technology builds on top of Struts and uses Struts techniques to validate user input. Error messages are shown using the NetUI tags instead of Struts tags. In this tutorial, you learn about how to enable server side input validation.


This tutorial is a continuation of WLSKB002. You must successfully complete that tutorial before starting this one.


Validation logic is entered in the form bean class. In our case, the name of the form bean class is LoginFormBean. It is a inner class of the Page Flow class LoginFlowController.

Double click on the LoginFlowController.jpf file to open it in the Page Flow editor. Click on the Source View tab at the bottom of the editor.

Scroll to the top of the class. Right below the line:

package LoginFlow;

Add a few import statements.

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

Scroll down and locate the LoginFormBean class.

Validation is performed from a method called validate(). The framework calls this method automatically after all the URL parameters have been transfered to the bean’s properties. Add the following method to the LoginFormBean inner class.

public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
 ActionErrors errs = new ActionErrors();

 if (getUserId() == null || getUserId().length() == 0) {
		 new ActionError("userid_missing"));
 if (getPassword() == null || getPassword().length() == 0) {
 errs.add("password_error", new ActionError("password_missing"));
 //Password must be 5 characters
 if (getPassword() != null && getPassword().length() < 5) {
 errs.add("password_error", new ActionError("password_short"));

 return errs;

Here, values like userid_error indicate the field in the form where the error took place. Values like userid_missingindicate a key to the error message in the message bundle file.

Note: Make sure that you have added the validate() method within the LoginFormBean inner class and not the LoginFlowController class.

Save changes (Control+S).


Every action can specify a page that is displayed when validation fails. In our case, we will like to redisplay the form – that is show the index.jsp page.

Locate the Login() method and specify the error handler page using the @jpf:validation-error-forward XDoclet tag as shown in boldface below.

 * @jpf:action
 * @jpf:forward name="success" path="home.jsp"
 * @jpf:forward name="failed" path="login_failed.jsp"
 * @jpf:validation-error-forward path="index.jsp" name="error"
 protected Forward Login(LoginFormBean form)

Save changes.


A message bundle (or resource bundle) file contains display text. It is often used to externalize translated multi-lingual text. In our case, we will store validation error messages there.

The message bundle file name must be specified for each Page Flow. To do that, scroll up the Page Flow source editor. Locate the line where the LoginFlowController class is declared.

 * </view-properties>
 * ::
 public class LoginFlowController extends PageFlowController

Specify the resourec bundle file name using the @jpf:message-resources XDoclet tag as shown in boldface below.

 * </view-properties>
 * ::
 * @jpf:message-resources resources="MyMessages"
 public class LoginFlowController extends PageFlowController

Save and close the file.

The message bundle files are stored in the WEB-INF/classes folder as shown below.

Right click on the classes folder and select New->Other File Types.


Change the file name to Click on Create.

Enter the following lines in the properties file.

error.prefix=<font color="red">
userid_missing=User id can not be empty.
password_missing=Password can not be empty.
password_short=Password must be at least 5 characters long.

Save and close the file.


Open index.jsp in the editor. Click on the Source View tab.

Show the error messages using the <netui:error> tag as shown in boldface below.

<netui:form action="Login">
 User ID:<br>
 <netui:textBox dataSource="{actionForm.userId}"/> 
 <netui:error value="userid_error"/> <br>
 <netui:textBox dataSource="{actionForm.password}" password="true"/> 
 <netui:error value="password_error"/> <br>
 <netui:button type="submit" value="Login"/>

Save and close the file.


Start the WebLogic server if it is not running (Tools->WebLogic Server->Start WebLogic Server).

Open a browser and enter the URL:

Try to create all three error conditions:

  1. Missing user ID
  2. Missing password
  3. Password less than 5 characters long.


After you complete this tutorial, make sure that you know:

  1. How to add data input validation logic in the form bean class.
  2. How to specify the validation error handler page for the action.
  3. How to create a message bundle file and specify the file name for the Page Flow.
  4. How to display validation error messages for each input field.