7 Replies Latest reply on Jan 26, 2010 2:51 PM by piotr.sobczyk

    Disabling "back" button - does it work for anyone?

    piotr.sobczyk
      We are using Seam 2.2.0 GA.

      In official Seam documentation there is a statement about pageflows feature:
      "Seam transparently detects the use of the back button, and blocks any attempt to perform an action from a previous, 'stale' page, and simply redirects the user to the 'current' page (and displays a faces message)."
      (The similar statement is in Seam in Action)

      We have a typical pageflow in our application (without back='disabled', we even tried with back='enabled') and the user can still freely navigate through previous views of conversation/pageflow using 'back' button. Disabling 'back' button doesn't work at all for us. We are sure though that pageflow is actually running.

      So we checked a numberguess example to be sure that we didn't do anything wrong in our pageglow definition file but numberguess behaves the same way (back button is still navigating to the previous page).

      Is this feature still supported by Seam?
        • 1. Re: Disabling "back" button - does it work for anyone?
          idyoshin

          I have a pageflows in seam 2.2.0 GA (seam-gen EAR application in JBossAS5.1.GA), and I was obligated to add "back" transition and commandButton for that in my pageflows in order to make my users enabled with back navigation.


          so I guess there is some configuration issue in your application.



          Regards,


          Ilya Dyoshin

          • 2. Re: Disabling "back" button - does it work for anyone?
            piotr.sobczyk

            Thanks for reply, Ilya. We have in fact very simple and short process definition, so I will let myself to paste it:


            <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.2.xsd"
                    name="Shopping Wizard">
                    
                    <start-page name="enteringOrder" view-id="/firstStep.xhtml" redirect="true"
                                    back="disabled">
                            <transition name="next" to="selectingArticles"/>
                    </start-page>
                    
                    <page name="selectingArticles" view-id="/secondStep.xhtml" redirect="true" back="disabled">
                            <transition name="next" to="viewingSummary"/>
                    </page>
                    
                    <page name="viewingSummary" view-id="/thirdStep.xhtml" redirect="true" back="disabled">
                            <transition name="next" to="end"/>
                    </page>
                    
                    <page name="end" view-id="/seller/reportPage.xhtml" redirect="true">
                            <end-conversation/>
                    </page>
            </pageflow-definition>
            



            and the pageflow starts here in pages.xml:


            <page view-id="/firstStep.xhtml">
                    <begin-conversation join="true" pageflow="Shopping Wizard"/>
            </page>
            



            And declaring jbpm in components.xml:


            <bpm:jbpm/>
            





            Can there be anything wrong in this configuration? Thanks in advance.

            • 3. Re: Disabling "back" button - does it work for anyone?
              piotr.sobczyk

              Could someone take a quick look on the very simple configuration above, please? Is there something wrong with it? It's important for us to have this freature working.


              We are using Tomcat 6, Seam 2.2.0 and have war application. (We have tried numberguess demo from examples on JBoss 4.2 and the back button is still enabled there).

              • 4. Re: Disabling "back" button - does it work for anyone?
                mikkus70

                There's nothing wrong in your configuration, I tried it and works (except I added the pageflow xml file in the <pageflow-definitions/> tag inside <bpm:jbpm/>).


                Probably, you're missunderstanding the way this feature works: if the browser is on step three of the pageflow, and you click the back button and go to step 1 or 2, you will see no errors, those pages will be rendered correctly (maybe even from browser cache).


                What the feature does is prohibit you from submitting anything from those pages you loaded via the back button. If you are on step 3 and use the back button to return to step 1, and click the next button, you'll be repositioned on step 3 and receive an Illegal navigation error.


                I tested this with Seam 2.2.0 and your sample pageflow and the behaviour described works correctly, so it is strange that it doesn't work for you... what submit action are you performing on those pages? To move to the next step in the pageflow, I use (the action parameter is the name of the transition to take to the next node):


                <h:commandButton action="next" value="Go to next step" />
                

                • 5. Re: Disabling "back" button - does it work for anyone?
                  piotr.sobczyk

                  Thanks A LOT for your time and attention, Emir.
                  You are right, I didn't understand this concept correctly. I was stupid enough to think that just after pressing back button by user, Seam magically handles it by redirecting him back to current view. And in that way user cannot reach previous pages by using back button. The term disable was probably the thing that misleaded me.


                  After your explanations I understand this feature perfectly. And it works for me just as you said it should. Thanks again!

                  • 6. Re: Disabling "back" button - does it work for anyone?
                    mikkus70

                    Piotr, I agree that disabling the back button is a misleading statement.


                    I think it is possible to obtain the behavior you indicate (issuing the Illegal navigation exception as soon as the back button is pressed). It should be enough to make a bogus submit after each page loads (via javascript). A submit would trigger the pageflow validation and returns the user to the correct page. It is not important what you submit, a simple empty field should be enough.

                    • 7. Re: Disabling "back" button - does it work for anyone?
                      piotr.sobczyk

                      Thanks again, Emir. It makes sense to me. We'll consider such solution. However it can be quite troublesome to submit page after each page load, event that is not caused by pressing back button (for example can bo source of ugly field cannot be empty validation messages).