1 2 Previous Next 15 Replies Latest reply on Jul 11, 2006 1:06 PM by gavin.king

    Breaking changes to pageflow

    gavin.king

      Tom and I made some breaking changes to Seam pageflow today. I've been trying to break as little as possible in 1.0, but this one was worth the pain.



      First:

      If you begin a pageflow while rendering the page (eg. from an @Factory or @Create method while pulling data for the page), you should no longer begin the pageflow with a <start-state>. This was an extremely inelegant model, since it implied a transition into the page we are already at!

      Instead, the first node of the pageflow should be a <start-page>. Take a look at the numberguess example to see what this looks like.

      Migration should be easy: simply delete three lines of code, and rename the first element to <start-page>.

      Note that where pageflows begin via an action method, the old way is still the correct way!

      Second:

      I have migrated to a CVS build of jBPM 3.1, which as of right now *requires* a jbpm.cfg.xml file even for pageflow. I'm going to try and work with Tom to make this change unnecessary, but for now, simply copy the jbpm.cfg.xml in the numberguess example into your project.

      Third:

      The awful seam-jndi.properties files are no longer required. Instead, Seam reads the jndi.properties file in embeddable-ejb/conf or microcontainer/conf.



      I hope that this stuff is not too disruptive.

        • 1. Re: Breaking changes to pageflow
          gavin.king

          Also note that all of the Seam examples (except for the remoting examples) now run on tomcat, and that we've now got a lot more tests :-)

          • 2. Re: Breaking changes to pageflow
            gavin.king

             

            "gavin.king@jboss.com" wrote:

            Second:

            I have migrated to a CVS build of jBPM 3.1, which as of right now *requires* a jbpm.cfg.xml file even for pageflow. I'm going to try and work with Tom to make this change unnecessary, but for now, simply copy the jbpm.cfg.xml in the numberguess example into your project.


            OK, this problem is now fixed. Ignore.

            • 3. Re: Breaking changes to pageflow

              How about making a new beta release of Seam - I have trouble trying to figure out which version of facelets, EL, etc... I need to build complete application .war (for a Seam + Hibernate + Facelets style of application)... even though I try to use recent nightly releases, follow the documentation, look at the example code, etc.

              Also, following the included readme.txt file doesn't cut it in the nightly builds.


              Get Up And Running Quick
              ------------------------

              1. Download JBoss AS 4.0.4.CR2 or later

              http://www.jboss.com/products/jbossas/downloads

              2. Install JBoss AS 4.0.4.CR2 with the EJB 3.0 profile selected

              3. Edit the "build.properties" file and change jboss.home to your
              JBoss AS installation directory

              4. Start JBoss AS by typing "bin/run.sh" in the JBoss home directory

              5. In the "examples/booking" directory, type "ant deploy" and check
              for any error messages

              6. Point your browser to

              http://localhost:8080/seam-booking/

              7. Register an account, search for hotels, book a room...


              Thanks

              • 4. Re: Breaking changes to pageflow
                dajevtic

                Hi. Any idea on when this start-page node will be supported by the eclipse ide? Great changes, by the way.

                Regards, dj

                • 5. Re: Breaking changes to pageflow
                  rpiaggio

                   

                  "gavin.king@jboss.com" wrote:

                  If you begin a pageflow while rendering the page (eg. from an @Factory or @Create method while pulling data for the page), you should no longer begin the pageflow with a <start-state>. This was an extremely inelegant model, since it implied a transition into the page we are already at!

                  Instead, the first node of the pageflow should be a <start-page>. Take a look at the numberguess example to see what this looks like.


                  How do I start with a decision node? I want my first page on the pageflow to respond to a decision.

                  • 6. Re: Breaking changes to pageflow

                    Have your start-node transition directly to a decision node. When the process is signaled, you will go through the decision node and, I assume, to a page node for display. If you are in the situation mentioned where you need use start-page, you I guess you'd need to find a way to inject the actual process instance somewhere and signal it.

                    • 7. Re: Breaking changes to pageflow
                      rpiaggio

                       

                      "norman.richards@jboss.com" wrote:
                      Have your start-node transition directly to a decision node. When the process is signaled, you will go through the decision node and, I assume, to a page node for display. If you are in the situation mentioned where you need use start-page, you I guess you'd need to find a way to inject the actual process instance somewhere and signal it.


                      That's what I am doing but the change described above seems to break the correct behavior.

                      Here's how my pageflow starts:
                      <pageflow-definition
                       name="PaymentAuthorization">
                       <start-state name="start">
                       <transition to="selectSource">
                       <action expression="#{sourceManager.selectSource}"/>
                       </transition>
                       </start-state>
                      
                       <decision name="selectSource" expression="#{sourceManager.result}">
                       <transition name="abort" to="menu"></transition>
                       <transition name="proceed" to="requestPin"></transition>
                       <transition name="chooseSource" to="chooseSource"></transition>
                       </decision>
                      


                      If the pageflow is started from this method via a POST it works:
                       @Begin(pageflow="PaymentAuthorization")
                       public void start() {
                       }
                      


                      However, if I started via a GET (calling the above method via pages.xml) or via a method anneotated like this:
                       @Begin(ifOutcome="proceed", pageflow="PaymentAuthorization")
                       public String initiate() {
                       ...
                       }
                      


                      then I get the following:
                      java.lang.ClassCastException: org.jbpm.graph.node.StartState
                       at org.jboss.seam.core.Pageflow.getPage(Pageflow.java:129)
                       ...


                      which seems to be a direct result of the change described above, since the start node is forced to cast to a Page, which of course fails if it is a <start-state> instead.

                      Any ideas on how to start with a decision when forced to start with a page?

                      • 8. Re: Breaking changes to pageflow
                        gavin.king

                        Try beginning the conversation from a Seam page action.

                        • 9. Re: Breaking changes to pageflow
                          rpiaggio

                          How do I specify the pageflow to start from pages.xml?

                          • 10. Re: Breaking changes to pageflow
                            gavin.king

                            Add a @Begin annotation to the page action method.

                            • 11. Re: Breaking changes to pageflow
                              rpiaggio

                              That's what I was doing when I said:

                               @Begin(pageflow="PaymentAuthorization")
                               public void start() {
                               }

                              However, if I started via a GET (calling the above method via pages.xml) ...


                              When I do that, I get the ClassCastException:
                              java.lang.ClassCastException: org.jbpm.graph.node.StartState
                               at org.jboss.seam.core.Pageflow.getPage(Pageflow.java:135)


                              due to this line in Pageflow.java:
                              public Page getPage()
                               {
                               return (Page) getNode();
                               }


                              (Line number has changed because I just upgraded to Seam 1.0.1 to make sure we are on the same page).

                              Seems to me that a page node is expected instead of a start state and so the exception is thrown.


                              Just in case, heres the extract from pages.xml:
                              <page view-id="/authorize.xhtml"
                               action="#{authorizer.start}" />
                              
                              and from AuthorizerAction.java:
                              @Name("authorizer")
                              @Stateful
                              @Scope(ScopeType.CONVERSATION)
                              public class AuthorizerAction implements Authorizer {
                              
                               @Begin(pageflow="PaymentAuthorization")
                               public void start() {
                               }


                              • 12. Re: Breaking changes to pageflow
                                rpiaggio

                                Ok, solved the problem.

                                The ClassCastException seems to happen when the flow cannot land on a page. In this case, the problem of not working on the page action seemed to derive from having an unnamed transition on the start-state. This would match on a normal action but not on the page action. This is how the pageflow and code looked like:

                                 <start-state name="start">
                                 <transition to="selectSource">
                                 <action expression="#{sourceManager.selectSource}"/>
                                 </transition>
                                 </start-state>
                                

                                @Begin(pageflow="PaymentAuthorization")
                                 public void start() {
                                 }
                                


                                Everything worked OK when I changed to:
                                <start-state name="start">
                                 <transition name="proceed" to="selectSource">
                                 <action expression="#{sourceManager.selectSource}"/>
                                 </transition>
                                 </start-state>
                                @Begin(pageflow="PaymentAuthorization")
                                 public String start() {
                                 return "proceed";
                                 }
                                


                                If this is a bug, it's a very minor one.

                                Actually, I think that having an unnamed transition should make it the default one, and should always be triggered when all other transitions don't match. This would ensure the pageflow always works. Any opinions on this feature request before I JIRA it?


                                • 13. Re: Breaking changes to pageflow
                                  gavin.king

                                  Do you understand the use of <start-page> in newer releases of Seam?

                                  • 14. Re: Breaking changes to pageflow
                                    rpiaggio

                                    I think I understand what there is in the documentation (and above in this thread):

                                    If we are beginning the pageflow during the RENDER_RESPONSE phase?during a @Factory or @Create method, for example?we consider ourselves to be already at the page being rendered, and use a <start-page> node as the first node in the pageflow, as in the example above.


                                    In my example, the pageflow is starting as a page action in one case and as an action in the other, so I don't think <start-page> applies. (Am I missing something?)

                                    It was probably a mistake to express my problem in this thread, I thought it was related to the change, sorry about that.

                                    The unnamed transition suggestion is orthogonal to both <start-page> and the problem and I was having.

                                    1 2 Previous Next