JSF navigation rules and action Processing

Source: Internet
Author: User

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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.