Navigation Rules
Navigation rules are the core of the wizard component. These rules must be included in the faces-config.xml file of the application. The following is a subset of the application rules. You can use these rules as a starting point to use the wizard components in your own applications.
/Main. jsp
If the action returns "next", goto firstSelection. jsp
Next
/FirstSelection. jsp
/FirstSelection. jsp
If the action returns "next", goto secondSelection. jsp
Next
/SecondSelection. jsp
If the action returns "back", goto main. jsp
Back
/Main. jsp
The navigation rule describes how to process an action based on the call location of the action, as shown below:
If the action is called on the "main. jsp" Page and "next" is returned, the navigation handler displays the "firstSelection. jsp" page.
If the action is called on the "firstSelection. jsp" Page and "back" is returned, go to the home page
If the called action returns "next", we will go to the "secondSelection. jsp" page.
Action
You can recall that the first page in the workflow is special, because the workflow can reload the page. The homepage is reloaded when you want to add characters to the orders table. This addition is implemented by placing a button in the page, which triggers the corresponding action when the button is pressed.
On the "main. jsp" page, you can see the button declaration:
The actual Action Handler is implemented in the ModelBean. java file. Add the "addCustomName" method to the table.
Public void addCustomName (ActionEvent event) throws AbortProcessingException {
If (customName! = Null )&&(! CustomName. trim (). equals ("") {customName = customName. trim ();
// Check to see if name already exists in list
Iterator iter = dataList. iterator ();
While (iter. hasNext ()){
CharacterBean item = (CharacterBean) iter. next ();
If (item. getName (). equals (customName )){
Reset ();
Return;
}
}
// Create new entry
CharacterBean item = new CharacterBean ();
Item. setName (customName );
Item. setSpecies (SpeciesBean)
SpeciesPropertyMap. get (customSpecies ));
DataList. add (item );
}
}
When a CommandButton with an action listener is called, the action program is called. The "addCustomName" method traverses the list of existing characters. If no new name is found in the list, it creates a new Character entry.
If the Action Handler has a return value, the navigation handler can use this value to determine the next action and determine the navigation direction based on the result. In this special example, no return value is returned, because only the same page is re-displayed, but a new username entry is added. The Design of action handlers and navigation handlers determines that they can be easily interconnected.