Passing parameters between pages
sukharevd May 9, 2011 9:55 AMHello,
it must be very newbie question, but I'm completely stuck passing parameters from one page to another. There is a bean with request scope and in navigation rules I'm using redirect. As far as I understood it's bad not to use this <redirect />, but still I don't want to change scope of my beans. How can I pass them in this case?
Now I have following:
<?xml version="1.0" encoding="UTF-8"?> <faces-config version="2.0" ... > <navigation-rule> <from-view-id>/categories.xhtml</from-view-id> <navigation-case> <from-outcome>Add Category</from-outcome> <to-view-id>/category_edit.xhtml</to-view-id> <redirect /> </navigation-case> <navigation-case> <from-outcome>Edit Category</from-outcome> <to-view-id>/category_edit.xhtml</to-view-id> <redirect /> </navigation-case> </navigation-rule> ... <application> <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver> <locale-config> <default-locale>en</default-locale> </locale-config> <resource-bundle> <base-name>messages</base-name> <var>messages</var> </resource-bundle> </application> </faces-config>
categories.xhtml:
<html ...> <ui:composition template="WEB-INF/pages/template.xhtml"> <ui:define name="body"> <f:view> <h:form id="categoryForm"> <rich:extendedDataTable rowKeyVar="rkv" frozenColCount="1" id="table" rows="40" columnClasses="col" value="#{categoryController.all}" var="item" sortMode="single"> <f:facet name="header"> <b>Category List</b> </f:facet> <rich:column sortExpression="#{item.title}"> <f:facet name="header"> <b>Category</b> </f:facet> <h:outputText value="#{item.title}" /> </rich:column> ... <rich:column sortExpression="#{item.parent}"> <f:facet name="header"> <b>Parent</b> </f:facet> <h:outputText value="#{item.parent}" /> </rich:column> <rich:column sortExpression="#{item.id}"> <f:facet name="header"> <b>Actions</b> </f:facet> <a4j:commandLink value="Edit" action="Edit Category"> <f:setPropertyActionListener value="#{item}" target="#{categoryController.category}" /> </a4j:commandLink> <h:outputText value=" " /> <a4j:commandLink value="Delete" action="#{categoryController.delete}" render="categoryForm"> <f:setPropertyActionListener value="#{item}" target="#{categoryController.category}" /> </a4j:commandLink> </rich:column> </rich:extendedDataTable> <a4j:commandButton value="Add Category" action="Add Category"/> </h:form> </f:view> </ui:define> </ui:composition> </html>
So when I press "Edit" appears ./category_edit.xhtml but with empty fields I don't know how to deal with this.