Tuesday, October 27, 2009

STEP 14: Add Navigation Rules

Add Navigation Rules to faces-config.xml

Projects (tab) | Expand ICEfacesLiferay001 | Expand Configuration Files | Double Click faces-config.xml | XML (button above diagram)

Edit faces-config.xml and add the three <navigation-rule> elements as shown in bold, below. Then save the file.

<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
    <managed-bean>
        <managed-bean-name>MyIcePortlet_view</managed-bean-name>
        <managed-bean-class>my.ice.faces.liferay.portlet.MyIcePortlet_view</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>MyIcePortlet_edit</managed-bean-name>
        <managed-bean-class>my.ice.faces.liferay.portlet.MyIcePortlet_edit</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>MyIcePortlet_help</managed-bean-name>
        <managed-bean-class>my.ice.faces.liferay.portlet.MyIcePortlet_help</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>

    <!-- **************** -->
    <!-- *              * -->
    <!-- *  NAVIGATION  * -->
    <!-- *              * -->
    <!-- **************** -->

    <navigation-rule>
        <from-view-id>/MyIcePortlet_edit.jspx</from-view-id>
        <navigation-case>
            <from-outcome>help</from-outcome>
            <to-view-id>/MyIcePortlet_help.iface</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>view</from-outcome>
            <to-view-id>/MyIcePortlet_view.iface</to-view-id>
        </navigation-case>
    </navigation-rule>

    <navigation-rule>
        <from-view-id>/MyIcePortlet_help.jspx</from-view-id>
        <navigation-case>
            <from-outcome>edit</from-outcome>
            <to-view-id>/MyIcePortlet_edit.iface</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>view</from-outcome>
            <to-view-id>/MyIcePortlet_view.iface</to-view-id>
        </navigation-case>
    </navigation-rule>

    <navigation-rule>
        <from-view-id>/MyIcePortlet_view.jspx</from-view-id>
        <navigation-case>
            <from-outcome>edit</from-outcome>
            <to-view-id>/MyIcePortlet_edit.iface</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>help</from-outcome>
            <to-view-id>/MyIcePortlet_help.iface</to-view-id>
        </navigation-case>
    </navigation-rule>

</faces-config>

Note: Because each page is represented by both a *.jspx and a *.iface extension, the page flow diagram in NetBeans can be confusing and should not be used. Therefore it is better to use the XML view of faces-config.xml to manage the ICEfaces JSF page flows.

3 comments:

  1. Hi,

    thanks for this tutorial ... do you know when you have time to finish it?

    Cheers,
    Benny

    ReplyDelete
  2. bbraeuer,

    I started adding the final steps today. Sorry to have kept you waiting. I grouped the posts all under Orctober, so they appear listed under a single month to make the right-side navigation easier.

    ReplyDelete