0

我想为 2 个 JSP 页面使用单个支持 bean。

我当前的 page1 和 page2 流程如下。现在 page1 和 page2 都想使用同一个支持 bean 来编辑 bean 中定义的对象。如何在 faces-config.xml 中写入条目?

       <navigation-rule>
    <from-view-id>/wizards/script/pag1.jsp</from-view-id>
    <navigation-case>
        <from-outcome>finish</from-outcome>
        <to-view-id>/wizards/script/page2.jsp</to-view-id>
    </navigation-case>
   </navigation-rule>
4

1 回答 1

0

您可以使用条件导航。见下面的例子。

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    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_2_0.xsd"
    version="2.0">

    <navigation-rule>
        <from-view-id>start.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>payment</from-outcome>
            <if>#{paymentController.orderQty &lt; 100}</if>
            <to-view-id>ordermore.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>payment</from-outcome>
            <if>#{paymentController.registerCompleted}</if>
            <to-view-id>payment.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>payment</from-outcome>
            <to-view-id>register.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>

</faces-config> 

有关更多信息,请查看http://www.mkyong.com/jsf2/conditional-navigation-rule-in-jsf-2-0/

于 2013-05-13T04:15:01.300 回答