Help

Controls

PermLinkWikiLink

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Forum: Seam Users Forum ListTopic List
28. Mar 2008, 16:18 CET | Link

I'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() {}
}

3 Replies:
29. Mar 2008, 18:53 CET | Link

Is countryManager used before you start the sub process?

 

Read about how to report a bug.

Rating:  *
31. Mar 2008, 08:29 CET | Link

Pete, as I wrote above : Why is selected country available only for bean and not directly on the page if bean is not touched ? The countryManager is not used before start of subprocess.

Dan, great answear, that explains it. I understand now that when entering subflow, a new request is started. I thought that it was still same request.

29. Mar 2008, 22:10 CET | Link

A data model selection is a request-scoped context variable. If you don't promote it to the conversation context, then it will not be able to live beyond a redirect, which is what I believe is happening in your page flow. The init() method is essentially promoting its scope so that it can be available.

Even if no redirect is occurring (and I am somehow wrong), you most certainly want the country to be in the conversation context anyway for the purpose of editing.

 

Dan Allen | mojavelinux.com | Author of Seam in Action

Rating:  * * * * *