HTML and CSS Reference
In-Depth Information
<!-- The flow can end by navigating to the cancel flow -->
<j:faces-flow-return id="cancel">
<!-- Method to execute when the flow has ended -->
Starting and ending flows
You start a flow by calling the ID of the flow in an action. You end a flow by returning the outcome defined in
faces-flow-return in the flow definition. Listing 5-18 shows how to use a command link to start and end a flow.
Listing 5-18. You Can Start a New Flow by Setting the Flow ID as the Action of a UICommand
<h:commandLink value="Click to add a new entry in the address book" action="newEntryFlow" />
<h:commandLink value="Cancel creating a new entry" action="/cancel" />
Stepping through the flow and storing data
There are two ways of storing flow data. You can either store it as properties on CDI beans annotated with
@FlowScoped, as shown in Listing 5-19, or you can add the data to a flow map that keeps whatever data you put into it,
as shown in Listing 5-20. Once the flow ends the map will be cleared.
Listing 5-19. FlowScoped Bean Controlling Logic and Storing Data
@FlowScoped(id = "newEntryFlow")
public class AddressBook implements Serializable {
private AddressBookEntry entry;
* Initialiser for the flow.
public void newEntry() {
this.entry = new AddressBookEntry();
* Determines if this is the first time the new entry flow is being used.
Search WWH ::

Custom Search