6 Replies Latest reply on Jul 29, 2009 4:31 PM by Israel Fonseca

    Page Scope and back-button

    Israel Fonseca Apprentice
      I have a page with a backing-bean scoped to page, in that page the user can do a lot of postbacks changing the page state. In that same page i have a button that return a String with a view-id, and when the user click that button the user go to another page. The problem is:

      Now in the second page the user hits the back-button of the browser, I expected that the sate of the page would remain the same old one (before I changed the page), but I got what i think that's a fresh new page. Shouldnt the old state be restored?

      From Seam Reference
      The state is actually serialized to the client, so this construct is extremely robust with respect to multi-window operation and the back button. "

      And that's happen even with the page scoped to session, and it's even more strange, cause after hiting the back button i got a cleaned page, but if i do a refresh, i got the old (and that's what i want) state.

      thks in advance,

        • 1. Re: Page Scope and back-button
          Arbi Sookazian Master

          Not sure if this is directly related to your question, but it may help shed some light on the topic:

          If a page is set to redirect after a transition, it is not possible to use the back button
          to return to that page even when back is enabled on a page later in the flow. The
          reason is because Seam stores information about the pageflow in the page scope
          and the back button must result in a POST for that information to be restored (i.e.,
          a Faces request). A redirect severs this linkage.

          Show your pages.xml.

          The <redirect/> element has the same effect as <redirect/>
          in a JSF navigation rule: namely, a post-then-redirect behavior, to overcome problems with the
          browser's refresh button.
          • 2. Re: Page Scope and back-button
            Israel Fonseca Apprentice
            Thks arbi i think that's the way to solve my problem. I'm not using pageflow or navigation rules in the page.xml, it's only programatically (navigation string on action method). What should i put in my page.xml?

            (Page A -> Page B) - Back Button on page B have to send the user back to Page A.

            The redirect tag is a sub-tag right? What's the parent tag for it?
            • 3. Re: Page Scope and back-button
              Arbi Sookazian Master


              <page view-id="/ManageEquipment.xhtml">
                       <description>Manage Equipment</description>
                       <action execute="#{manageSiteId.init}"/>                  
                       <navigation from-action="#{manageEquipment.processRepairHistorySelection}">
                            <redirect view-id="/RepairCaseDetails.xhtml"/>                          
                      <navigation from-action="#{manageEquipment.searchSerialNumber}">
                           <redirect view-id="/ManageEquipment.xhtml"/>

              The advantage of having all your page navigation in one place (i.e. the pages.xml file) is that it's easier to read the overall page flow of your app.

              • 4. Re: Page Scope and back-button
                Israel Fonseca Apprentice
                I'm still getting problems Arbi. Look at my 2 page.xml from my views. The first one (Page A):

                     <navigation from-action="#{consultarComprovante.selecionar(subitem)}">
                          <redirect view-id="/pages/usuario/consultarParcelaVenda.xhtml"/>

                Ok no problem, when i invoke that action i go to the other page. And that page (Page B) have this page.xml

                     <navigation >
                          <rule if="#{consultarParcela.comprovante == null}">
                               <redirect view-id="/pages/usuario/consultarComprovante.xhtml">
                                    <message severity="WARN">Selecione um comprovante primeiro.</message>

                Only a check to prevent the user to coming directly to this page first, ignore it. The problem is: now in the second page if use the browser back-button (Firefox), i'm back to a fresh page, not the old one. Remember i'm using page-scope with both backing-beans of the page.

                I didnt understand where i have to put the redirect tag in this situation as you told me to do in your first post.

                Thks again,

                • 5. Re: Page Scope and back-button
                  Israel Fonseca Apprentice

                  After doing some research and testing... all these back button problem are cause by intensive use of a4j/rich components. It looks like that the page scope don't like them or something like it. I'm going to post my example in richfaces forum.