jsf - How to use one backing bean for 2 JSP pages -
i want use single backing bean 2 jsp pages.
my current flow page1 , page2 follows. both page1 , page2 wants use same backing bean edit objects defined in bean. how write entries in 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>
you can use conditional navigation. see following example.
<?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 < 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>
for more information check http://www.mkyong.com/jsf2/conditional-navigation-rule-in-jsf-2-0/
Comments
Post a Comment