An extract from Anghel Leonard's book,
<view tag>
: It is nested in the<flow-definition>
tag and indicates the JSF pages that represent the flow nodes; it associates an explicit ID to each page (Facelet) path (further, you can refer to each page by its ID). The page path is mapped in a<vdl-document>
tag, nested in the<view>
tag. The presence of this tag is optional, but as a convention, at least the<view>
tag indicating the start node (start page) is present, especially if you want to set another start node besides the default one, which is represented by the page in the flow with the same name (ID) as the flow. Further, you can use the optional<start-node>ID</start-node>
tag and indicate the ID of the<view>
tag that maps the custom starting page. As an alternative, the start node of the flow can be indicated by setting the value of the id attribute of a tag as the flow ID, and the content of the encapsulated tag as the path of the custom starting page. When you refer to the flow ID, JSF will go to that page and automatically put you in the flow.
Suppose I have 4 pages which are relative to webapp
directory as shown:
index.xhtml
registration/registration.xhtml
registration/confirm.xhtml
done.xhtml
The author suggests this setting in faces-config.xml
:
<flow-definition id="registration">
<view id="registration">
<vdl-document>/registration/registration.xhtml</vdl-document>
</view>
<flow-return id="taskFlowReturnIndex">
<from-outcome>/index</from-outcome>
</flow-return>
<flow-return id="taskFlowReturnDone">
<from-outcome>/done</from-outcome>
</flow-return>
</flow-definition>
I have experiment it, and came to know that indeed,
<view id="registration">
<vdl-document>/registration/registration.xhtml</vdl-document>
</view>
is optional as also put forward by the same author.
This is sufficient (the id
attribute bearing the same name as of JSF view from where a flow needs to be created.)-
<flow-definition id="registration">
...
</flow-definition
Furthermore, the flow will only be created if the id
attribute for <flow-definition id="registration">
exactly matches the name of the JSF view, i.e:
registration
.xhtml
Repeating a portion of the same extract:
...at least the
<view>
tag indicating the start node (start page) is present, especially if you want toset another start node
besides thedefault one
, which is represented by the page in the flow with thesame name (ID)
as the flow. Further, you can use the optional<start-node>ID</start-node>
tag and indicate theID
of the<view>
tag that maps the custom starting page.
Put in much simpler words, he suggests like this to be done nested within the same <flow-definition>
,
<view id="confirm">
<vdl-document>/registration/confirm.xhtml</vdl-document>
</view>
<start-node>confirm</start-node>
But I see that going from index.xhml
to confirm.xhtml
doesn't return true
for
In flow ? #{null != facesContext.application.flowHandler.currentFlow}
as for when one navigates from index.xhtml
to confirm.xhtml
.
Any suggestions?