DataTable selected object and its presence in context
blabno Mar 28, 2008 4:18 PMI've noticed strange bahavior of dataTable selected object and its presence in context. I have two pageflows browseCountries
and editCountry
. The latter is subflow. When I am on countriesList.xhtml page (browseCountries
pageflow), and click on a country from dataTable to edit it a new subflow is started - the editCountry
pageflow. I want to display data of selected country there, but there is nothing in a context.
However if I add following code to editCountry
pageflow definition the selected country gets injected into bean's attribute and outjected into context, and thus available on editCountry.xhtml
page.
<start-state> <transition to="editForm"> <action expression="#{countryManager.init}"/> </transition> </start-state>
Could anybody explain why is this happening ? Why is selected country available only for bean and not directly on the page if bean is not touched ?
I attach code of my beans, jPDL's and xhtml's for reference. They are of course trimmed to show only what is important.
<pageflow-definition name="browseCountries"> <start-page name="countriesList" view-id="/countriesList.xhtml"> <transition name="edit" to="editCountry"/> </start-page> <process-state name="editCountry"> <sub-process name="editCountry"/> <transition to="countriesList"/> </process-state> </pageflow-definition>
<pageflow-definition name="editCountry"> <start-state> <transition to="editForm"> <action expression="#{countryManager.init}"/> </transition> </start-state> ... </pageflow-definition>
countriesList.xhtml
<h:dataTable value="#{countries}" var="country"> <h:column> <h:selectBooleanCheckbox value="#{countryBrowser.selectedCountries[country]}"/> </h:column> <h:column> <h:commandLink action="edit" value="#{country.name}"/> </h:column> </h:dataTable>
editCountry.xhtml
<h:form> <h:outputText value="#{messages.countryName}"/> <h:inputText value="#{country.name}"/> </h:form>
ManageCountryActionBean.java
@Stateful @Name("countryManager") public class ManageCountryActionBean implements ManageCountryAction { @In(value = "country", create = true) @Out(value = "country") private Country country; /** * Initiates bean attributes. * Method should be called from pageflow descriptor. */ public void init() {} }