8 Replies Latest reply on Feb 1, 2010 3:46 AM by Ilya Shaikovsky

    Reset viewId on a4j:include

    Mason Harding Newbie

      Hi all.  I have an a4j:include that I'm using as a wizard.  All works very well, but I triger an action outside of the a4j:include that ends the wizard.  When I lanch the wizard again, its still on the last page of the a4j:include wizard.

       

      So its <a4j:include viewId="/page1.xhtml"/>, which uses page1.page.xml to render page2, then page 3.  After I end the wizard, and re-open it, it's still on page3.  How can I get that to always start with page1?

       

      Please let me know if source code is needed for this, and I will clean some up and paste it.

       

      Thanks for your help!

      -Mason

        • 1. Re: Reset viewId on a4j:include
          Ilya Shaikovsky Master
          just define viewId with EL binding to some bean property and reset it in cancel/save actions.
          • 2. Re: Reset viewId on a4j:include
            Mason Harding Newbie
            Thank you so much Ilya.  That did the trick.  For anyone else using seam to runs into this problem...please see 6.9 of http://docs.jboss.org/seam/2.0.1.CR1/reference/en/html/conversations.html for How to set up the binding.
            • 3. Re: Reset viewId on a4j:include
              Anton Lisovenko Newbie

              Hi.

               

              I have problems with implementing what Ilya advised

               

              First I tried to set the viewId through the bean property:

               

              <a4j:include viewId="#{bean.viewId}" />

               

               

              Then tried binding:


              <a4j:include binding="#{orderDetailsBean.quickClosePanel}" viewId="template/orders/quick_close_order_modal.xhtml" />

               

              OrderDetails Bean:

               

               

              public class OrderDetailsBean {

                   private Include quickClosePanel;

              ....

              }

               

              and reseting the value id on the close operation (this is the seam conversational bean, which calls orderDetailsBean for bound include):

               

               

              @End
                  public void endConversation() {
                      orderDetails().getQuickClosePanel().setViewId("template/orders/quick_close_order_modal.xhtml");              
                  }

               

               

              Interesting, that at the moment of calling "setViewId" method the include already has the initial "template/orders/quick_close_order_modal.xhtml" value. So this setter is not necessary at all. But anyway the last view in the include is shown, not the first one.

              • 4. Re: Reset viewId on a4j:include
                Ilya Shaikovsky Master

                seems you not reRender'ed your wizard.

                • 5. Re: Reset viewId on a4j:include
                  Anton Lisovenko Newbie

                  On which stage?

                   

                  I rerender the wizard on its opening. I tried also to rerender it on last wizard page close, but this results on last page show.

                   

                  Here are my snippets:

                   

                  main page:

                   

                  <!-- Link -->
                  <a4j:commandLink action="#{quickCloseOrderBean.prepareClose}"
                                  oncomplete="if (!isError(#{facesContext.maximumSeverity.ordinal})) rerenderQuickClose();"
                                  value="#{orders_bundle.quickClose}">
                  <a4j:jsFunction name="rerenderQuickClose" reRender="quick_close_area"/>

                  .....


                  <!-- Wizard -->

                  <a4j:outputPanel>
                        <a4j:include binding="#{orderDetailsBean.quickClosePanel}"
                                  viewId="template/orders/quick_close_order_modal.xhtml" id="quick_close_area" />
                  </a4j:outputPanel>

                   

                  quick_close_order_modal.xhtm (first view in the wizard)l:

                   

                  <al:confirmationModal showWhenRendered="#{quickCloseOrderBean.conversationStarted}"
                          backingBean="#{quickCloseOrderBean}"
                          action="doClose">
                  ....
                  </al:confirmationModal>

                  <!-- <al:confirmationModal > - is a facelets tag, containing the rich:modalPanel with two buttons 'ok' and 'cancel'. On 'ok' click the quickCloseOrderBean.doClose() action is called, which returns the next page viewId - the 'quick_close_order_result.xhtml. -->

                   

                  quick_close_order_result.xhtml (the last view in the wizard):

                   

                  <al:alertModal  showWhenRendered="#{quickCloseOrderBean.conversationStarted}"
                          backingBean="#{quickCloseOrderBean}"
                          action="endConversation" reRender="detForm, quick_close_area">

                  <!-- <al:alertModal > - is a facelets tag, containing the rich:modalPanel with the only button 'ok'. This ends the conversation and closes the modal panel. -->

                   

                  I tried different ways, on the close of the last modal panel ("endConversation" method) I reset the viewId of the a4j:include (although it is already set to the initial value!!), I even rerender the a4j:include (I tried to rerender the container, where a4j:include is located) - but again on the link click I see the last viewId, not the first one...

                   

                  Any help appreciated!

                  • 6. Re: Reset viewId on a4j:include
                    Ilya Shaikovsky Master
                    finally found an article which contains good sample of include reset. http://java.dzone.com/articles/jboss-richfaces-spring?page=0,0
                    • 7. Re: Reset viewId on a4j:include
                      Anton Lisovenko Newbie

                      Hi.

                       

                      I found the resolution to the issue at last...

                       

                      I used the keepAlive tag for my orderDetails bean. And the binding #{orderDetails.quickClosePanel} didn't work correctly in this case - meaning that the manual changings to the bound Include component didn't affect the real component tree and the component itself.. I cannot actually explain why, but I can say, that bindings should be used very carefully with those beans, which are serialized to the component tree (a4j:keepAlive is used). May be Ilya could better explain this interesting issue...

                       

                      So, if anyone is interested - the code, which I provided above (with binding) works well, but do not bind the include tag to the bean, which is serialized through the requests! Take a simple request bean and use it

                       

                      Ilya, thanks for your support again, it's great to know, that the one will not be left alone with any RF problems

                      • 8. Re: Reset viewId on a4j:include
                        Ilya Shaikovsky Master
                        Yes, JSF components in general should not be placed to session scope (many explanations across this forum and at any JSF related resources present). And even worst idea is to serialize the bean which contains binding using keepAlive. It restored after restore phase. So request scoped bean created and binding object instantiated during restore component tree and then it gets overriden after keep alive restore bean.