Skip to main content

JSF Tip #57 - Using a different start node in Faces Flows

Posted by mriem on February 6, 2014 at 2:12 AM PST

By convention in Faces Flows the page that is the start node has the same name as the flow, but is it possible to change that? It sure is, read on!

We'll dive into the Faces configuration file that will make this work.

<faces-config version="2.2"
              xmlns="http://xmlns.jcp.org/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
    <flow-definition id="indexflow">
        <start-node>index</start-node>
        <view id="index">
            <vdl-document>/indexflow/index.xhtml</vdl-document>
        </view>
        <flow-return id="indexFlowReturn1">
            <from-outcome>/exit</from-outcome>
        </flow-return>
    </flow-definition>
</faces-config>

In the configuration file above you see the start-node is defines as 'index' and then the next XML element defines a view with the name of 'index' and then refers to a vdl-document, that VDL document is a reference to the actual page that is going to be the start-node.

This is all you need to define a different start-node.

Note the code for this sample is available as part of the Glassfish samples (see the subversion repository at https://svn.java.net/svn/glassfish-samples~svn/trunk/ws/javaee7/jsf/indexFlow/)

And that is it!

Enjoy

Related Topics >>