Working with Page Navigation in JSF Facelets Applications
JSF Facelets supports an implicit navigation that reduces navigation-related code required in the faces-config.xml file. With implicit navigation, you can omit explicit navigation-rule elements in the faces-config file and instead have your action handler method return one of the following values:
To stay on the same page, return null.
To switch to a different view, return the viewId of the target view.
The navigation handler first checks the navigation rules in the faces-config.xml for a matching navigation case. However, if a matching navigation case is not found, the navigation handler checks to see whether the action outcome is null or a value that corresponds to a viewId.
For example, the following action handler methods demonstrate how an action handler can take advantage of the implicit navigation:
public String doActionThatStaysOnSamePage() {
//TODO: do your action logic here
//return null to stay on the same page
return null;
}
public String doActionThatSwitchesToPage2() {
//TODO: do your action logic here
//return the viewId of the page to switch to
return "/yourportlet/page2.view";
}
For more information about JSF Facelet default navigation handling, see the JSF Facelet standard.
Note:
If you are migrating a JSF .view file project to JSF Facelet format and you have action handlers that return OUTCOME_OK or OUTCOME_ERROR, you should update the logic. For example, you might want the action handlers to return null instead.
Related Topics