HTML and CSS Reference
In-Depth Information
Listing 2-29. The ExampleBean Managed Bean
@ManagedBean
@RequestScoped
public class ExampleBean implements Serializable {
public String doAction() {
if (validateInformation()) {
return "success";
} else {
return "fail";
}
}
private boolean validateInformation() {
/* Some calls can be performed to the business services here ... */
}
}
As indicated in the preceding, the <from-action> element is an optional one, which means that the JSF
navigation can work by specifying the <from-outcome> element only. Listing 2-30 shows two navigation cases without
the <from-action> elements.
Listing 2-30. Rule-Based Navigation Example 2
<faces-config ...>
<navigation-rule>
<from-view-id>/index.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/welcome.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>fail</from-outcome>
<to-view-id>/invalid.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
When the <from-action> element is omitted, the <from-outcome> String literal is compared with the action
attribute of the action source components ( commandButton or commandLink ). This means that if we have any
commandButton or commandLink whose action 's value (or evaluated expression value) is "success" then the first
navigation case will fire, and when it is "fail" then the second navigation case will fire.
Adding to the action source components, the <from-outcome> String literal is also compared with the outcome
attribute of the <h:link> and the <h:button> components.
Search WWH ::




Custom Search