14 Replies Latest reply on Feb 22, 2009 4:22 PM by pkayjava

    Create a nested conversation from JPDL pageflow ?

    gjeudy

      Hi,


      I want to reuse a backing SFSB from a pageflow. My goal is to have 1 or more instances of the same backing SFSB through the course of the pageflow.


      What would be the best approach to solve this problem ? I can use @Role to reference the SFSB as a different name, when the name is different and matches a @Role name a new instance is created. In this model all instances of the bean live in the same conversation.


      Could I achieve this re-usability using a nested conversation instead ? With this approach each instance would live in it's own nested conversation and no @Role trick would have to be used. Is it possible to create a nested conversation from a JPDL pageflow ? I tried to trigger a nested conversation with an action in the JPDL pageflow:


      <page name="addProductFamilyRel" view-id="/addProductFamilyRel.xhtml">
      
                   <transition name="prev" to="editProduct" />
      
                   <transition name="next" to="addCoverageRel">
      
                      <action expression="#{productAction.saveProductFamilyRel}" />
      
                      <action expression="#{reusablebean.beginNestedConversation}" />
      
                   </transition>
      
                   <transition name="cancel" to="end" />
      
         </page>



      On the transition reusable bean begins a nested conversation through annotated method.


      @Begin(nested=true)
      
      public void beginNestedConversation()
      
      



      The above caused seam to redirect to the current page in the JPDL pageflow even if transition next was submitted.


      Has anyone played with similar setups ? I might be missing understanding but it looks like its not possible to use nested conversations from JPDL.


      Best regards,
      -Guillaume

        • 1. Re: Create a nested conversation from JPDL pageflow ?
          barbacena

          I am waiting a answer for this as well.


          Nesting pageflow

          • 2. Re: Create a nested conversation from JPDL pageflow ?
            blabno

            This is how i nest conversations in jPDL. Take a look at the editCountry node.


            <?xml version="1.0" encoding="UTF-8"?>
            <pageflow-definition
                xmlns="http://jboss.com/products/seam/pageflow"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://jboss.com/products/seam/pageflow http://jboss.com/products/seam/pageflow-2.0.xsd"
                name="browseCountries">
                
                <start-page name="countriesList" view-id="/admin/manageCountries/countriesList.xhtml">
                    <transition name="remove" to="confirmCountriesRemoval"/>
                    <transition name="edit" to="editCountry"/>
                    <transition name="add" to="editCountry">
                        <action expression="#{countryBrowser.initAddCountryAction}"/>
                    </transition>
                    <transition name="finish" to="end"/>
                </start-page>
                
                <page name="confirmCountriesRemoval" view-id="/admin/manageCountries/confirmCountriesRemoval.xhtml" no-conversation-view-id="/admin/index.xhtml">
                    <transition name="next" to="countriesList">
                        <action expression="#{countryBrowser.removeSelectedCountries}"/>
                    </transition>
                    <transition name="cancel" to="countriesList"/>
                </page>   
                
                <process-state name="editCountry">        
                    <sub-process name="editCountry"/>     
                    <transition to="countriesList"/>
                </process-state>
                
                <page name="end" view-id="/admin/home.xhtml">
                    <end-conversation/>
                    <redirect/>
                </page>
                
            </pageflow-definition>



            editCountry.jpdl.xml


            <?xml version="1.0" encoding="UTF-8"?>
            <pageflow-definition
                xmlns="http://jboss.com/products/seam/pageflow"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://jboss.com/products/seam/pageflow
                http://jboss.com/products/seam/pageflow-2.0.xsd"
                name="editCountry">
                
                <start-state>
                    <transition to="editForm">
                        <action expression="#{countryManager.init}"/>
                    </transition>
                </start-state>
                
                <page name="editForm" view-id="/admin/manageCountries/editCountry.xhtml">
                    <transition name="cancel" to="end">
                        <action expression="#{countryManager.revert}"/>
                    </transition>
                    <transition name="next" to="end">
                        <action expression="#{countryManager.save}"/>
                    </transition>
                    <transition name="add" to="editRegion">
                        <action expression="#{countryManager.initAddRegionAction}"/>
                    </transition>
                    <transition name="edit" to="editRegion"/>
                    <transition name="remove" to="confirmRegionsRemoval"/>
                </page>
                
                <process-state name="editRegion">
                    <sub-process name="editRegion"/>
                    <transition to="editForm"/>
                </process-state>
                
                <page name="confirmRegionsRemoval" view-id="/admin/manageCountries/confirmRegionsRemoval.xhtml">
                    <transition name="cancel" to="editForm"/>
                    <transition name="next" to="editForm">
                        <action expression="#{countryManager.removeSelectedRegions}"/>
                    </transition>
                </page>
                
                <end-state name="end"/>
                
            </pageflow-definition>

            • 3. Re: Create a nested conversation from JPDL pageflow ?
              gjeudy

              Hi,


              Thanks Bernard for your input but your solution does not create a nested conversation (unless you omitted some code/XML in your example ?). The beans participating in the subprocess are still part of the parent conversation/pageflow.


              The seam debug page shows that no nested conversation were created when navigating to the subprocess page. Your proposal is good to re-use jpdl descriptions but doesn't help me in my case.


              It looks like jpdl does not support nested conversations and I will have to ditch this option if I want to use nested convos.


              PS: If I don't add the file defining the subprocess in components.xml before the parent pageflow, I get a NullPointerException, it would be nice if Seam handle this more gracefully.


              2008-04-01 08:39:41,489 ERROR [org.jbpm.jpdl.xml.JpdlXmlReader] couldn't parse process definition
              
              java.lang.NullPointerException
              
                   at org.jbpm.graph.node.DbSubProcessResolver.findSubProcess(DbSubProcessResolver.java:43)
              
                   at org.jboss.seam.bpm.Jbpm$SeamSubProcessResolver.findSubProcess(Jbpm.java:332)
              
                   at org.jbpm.graph.node.ProcessState.read(ProcessState.java:108)
              
                   at org.jbpm.jpdl.xml.JpdlXmlReader.readNodes(JpdlXmlReader.java:260)
              
                   at org.jboss.seam.bpm.PageflowParser.readNodes(PageflowParser.java:41)
              
                   at org.jbpm.jpdl.xml.JpdlXmlReader.readProcessDefinition(JpdlXmlReader.java:156)
              
                   at org.jboss.seam.bpm.Jbpm.parseInputSource(Jbpm.java:317)
              
                   at org.jboss.seam.bpm.Jbpm.getPageflowDefinitionFromResource(Jbpm.java:155)
              
                   at org.jboss.seam.bpm.Jbpm.installPageflowDefinitions(Jbpm.java:235)
              
                   at org.jboss.seam.bpm.Jbpm.startup(Jbpm.java:73)
              
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              
                   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              
                   at java.lang.reflect.Method.invoke(Method.java:585)
              
                   at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
              
                   at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
              
                   at org.jboss.seam.Component.callComponentMethod(Component.java:2082)
              
                   at org.jboss.seam.Component.callCreateMethod(Component.java:2005)
              
                   at org.jboss.seam.Component.newInstance(Component.java:1976)
              
                   at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
              
                   at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
              
                   at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:95)
              
                   at org.jboss.seam.init.Initialization.init(Initialization.java:583)
              
                   at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34)
              
                   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856)
              
                   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)
              
                   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790)
              
                   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770)
              
                   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
              
              


              • 4. Re: Create a nested conversation from JPDL pageflow ?
                barbacena

                Subprocess is not the same as nesting. Its more like a include!
                We need a way to nest! It could be a parameter in the subprocess node like:


                <sub-process name="editCountry" nest="true" />



                or


                <sub-process name="editCountry" propagation="nest" />



                • 5. Re: Create a nested conversation from JPDL pageflow ?
                  pmuir

                  Make sure there is a feature request in JIRA.

                  • 6. Re: Create a nested conversation from JPDL pageflow ?
                    barbacena

                    Created:


                    JBSEAM-2854

                    • 7. Re: Create a nested conversation from JPDL pageflow ?
                      lexsoto

                      Marcell:


                      I have this same problem.  Have you found a workaround ?
                      I've been trying to explicity begin and end a nested conversation for the sub process. I'm able to begin the nested conversation when transiting to the subprocess but unable to end the conversation when the subprocess ends.


                      java.lang.IllegalStateException: pageflow is not currently at a <page> or <start-page> node (note that pageflows that begin during the RENDER_RESPONSE phase should use <start-page> instead of <start-state>)
                      
                           org.jboss.seam.pageflow.Pageflow.getPage(Pageflow.java:227)
                      
                           org.jboss.seam.pageflow.Pageflow.navigate(Pageflow.java:237)
                      
                           org.jboss.seam.pageflow.Pageflow.navigate(Pageflow.java:337)
                      
                           org.jboss.seam.jsf.SeamNavigationHandler.handleNavigation(SeamNavigationHandler.java:40)
                      
                           com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:119)
                      
                           javax.faces.component.UICommand.broadcast(UICommand.java:383)
                      
                           javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
                      
                           javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
                      
                           com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
                      
                           com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                      
                           com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
                      
                           javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
                      
                           org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)




                      Any help will be appreciated.

                      Thanks,

                      -Alex

                      • 8. Re: Create a nested conversation from JPDL pageflow ?
                        gjeudy

                        Alex, good luck in trying a workaround. If I were you I would not try to implement something that is not officially supported by Seam.


                        As you can see a feature request JBSEAM-2854 is already entered, you should vote for it to increase the likelihood that it will be implemented in a future release.


                        Regards,
                        -Guillaume

                        • 9. Re: Create a nested conversation from JPDL pageflow ?
                          barbacena

                          Alex,


                          I switched to JSF page navigation for the time being waiting JBSEAM-2854 be implemented. Please vote the issue.


                          p.s.: curiosity, how did you nest the conversation?

                          • 10. Re: Create a nested conversation from JPDL pageflow ?
                            lexsoto

                            Thank you Guillaume and Marcell.

                            I've now voted for the issue.

                            -Alex

                            • 11. Re: Create a nested conversation from JPDL pageflow ?
                              marcincaban
                              I had gone one step future.
                              IllegalStateException could be omnited, when no "pageflow" attribute is used with "@Begin" annotation.
                              I've got another problem - transitions from nested pageflow does not work after starting a nested conversation.
                                      <page name="xxx" view-id="/aaa.xhtml" redirect="true">
                                              <transition name="ssss" to="end">
                                                      <action expression="#{qqqq.wwww()}" />
                                              </transition>
                                      </page>
                              • 12. Re: Create a nested conversation from JPDL pageflow ?
                                marcincaban
                                15:37:31,546 DEBUG [lifecycle] Entering InvokeApplicationsPhase

                                15:37:31,546 DEBUG [application] processAction(ffffffffffffButton)

                                15:37:31,546 DEBUG [application] "JSF1013: Unable to find matching navigation case from view ID '/aaa.xhtml' for outcome 'ssss' and action 'ssss'

                                15:37:31,546 DEBUG [lifecycle] Exiting InvokeApplicationsPhase
                                • 13. Re: Create a nested conversation from JPDL pageflow ?
                                  pkayjava

                                  i am replying to this error,
                                  PS: If I don't add the file defining the subprocess in components.xml before the parent pageflow, I get a NullPointerException, it would be nice if Seam handle this more gracefully.


                                  Please add page flow definition in components.xml by logical order



                                                  <bpm:pageflow-definitions>
                                                          <value><![CDATA[sub_page_process_state.jpdl.xml]]></value>
                                                          <value><![CDATA[main_page_flow.jpdl.xml]]></value>
                                                  </bpm:pageflow-definitions>




                                  I hope, it will work in ur case,


                                  because i am also get this null pointer exception error,
                                  and i went and re order it, and it works.

                                  • 14. Re: Create a nested conversation from JPDL pageflow ?
                                    pkayjava

                                    i am replying to this error, PS: If I don't add the file defining the subprocess in components.xml before the parent pageflow, I get a NullPointerException, it would be nice if Seam handle this more gracefully.


                                    Please add page flow definition in components.xml by logical order


                                                    <bpm:pageflow-definitions>
                                                            <value><![CDATA[sub_page_process_state.jpdl.xml]]></value>
                                                            <value><![CDATA[main_page_flow.jpdl.xml]]></value>
                                                    </bpm:pageflow-definitions>




                                    I hope, it will work in ur case,


                                    because i am also get this null pointer exception error, and i went and re order it, and it works.