1 2 Previous Next 20 Replies Latest reply on Jul 7, 2009 8:54 AM by Karoly Torok

    question about a4j:include and navigation rules

    liumin hu Master

      hi,

      In the a4j:include example, we use navigation rules for wizzard. i want to know if it is possible to have a commandbutton to reset the page included to first.xhtml in the page demo.xhtml. something like

      <a4j:form>
      <a4j:commandButton action="#{person.resetLink}" value="reset" reRender="wizard"/>
      </a4j:form>
      <h:panelGroup id="wizard">
      <a4j:include viewId="#{person.includePage}"/>
      </h:panelGroup>
      


      in Person.java
       public void resetLink() {
       this.includePage = "/pages/first.xhtml";
       }
      


        • 1. Re: question about a4j:include and navigation rules
          Michael Steiner Newbie

          I have exactly the same problem. I have to reset wizard to the first page outside included page. Any ideas ?

          • 2. Re: question about a4j:include and navigation rules
            Michael Steiner Newbie

            Ok I finally managed to make it works.

            <a4j:form>
            
            <a4j:commandButton action="#{ModalPanel.reset}" value="reset" reRender="wizard"/>
            
            </a4j:form>
            
            <a4j:outputPanel id="wizard" ajaxRendered="true">
             <a4j:include binding="#{ModalPanel.uiinclude}" viewId="#{ModalPanel.viewId}" />
            </a4j:outputPanel>
            

            My ModalPanel bean.
            public void reset() {
             //go to first page
             uiinclude.setViewId("/inc/first.xhtml");
             }
            





            • 3. Re: question about a4j:include and navigation rules
              mohan Newbie

              Hello,

              I have the same situation. instead of command button i have <a4j:commandLink>

              Can i get help on binding. sample code in bean to set binding like in example

              binding="#{ModalPanel.uiinclude}"

              Thanks

              • 4. Re: question about a4j:include and navigation rules
                mohan Newbie


                My jsp page contains

                <a4j:commandLink value="change Page" action="#{test.action}" />
                
                 <a4j:outputPanel id="wizard" ajaxRendered="true">
                 <a4j:include viewId="#{test.page}" />
                 </a4j:outputPanel>
                


                and bean contains

                private String page = "First.jsp";
                
                public String getPage() {
                 return page;
                }
                
                public void setPage(String page) {
                 this.page = page;
                }
                
                public void action()
                {
                 setPage("Second.jsp");
                }
                


                but the jsp page is not updating with new page included.



                • 6. Re: question about a4j:include and navigation rules
                  mohan Newbie

                  Thanks for reply,

                  I tried reRender also. The outpanel rerenders if it contains some other components like link, outputtext etc. but not when it contains <a4j:include>.
                  I don't know why ???

                  also, since i set ajaxRendered="true" in outputPanel I think i don't need rerender explicitely in my link.


                  • 7. Re: question about a4j:include and navigation rules
                    Sergey Smirnov Master

                    The commandButton must be inside the included content to make navigation workable.

                    Also, since Ajaxjsf 1.1.1, using a4j:outputPanel around the a4j:include is not required any more.

                    • 8. Re: question about a4j:include and navigation rules
                      Vidur Dhanda Newbie

                      Disclaimer: This is my first real application using these technologies.
                      I?m using JSF (1.2), Facelets (1.1.12), Ajax4Jsf (1.1.1) and RichFaces (3.0.1).

                      Here?s a motivating example:
                      A form allows a user to enter a Purchase Order. A Purchase Order has some header information such as customer name, etc. A Purchase Order also has many Line Items. A Line Item corresponds to a specific product, quantity, price, etc., that is being purchased. While editing a Purchase Order, I want the viewer to be able to add multiple Line Items.

                      I use rich:modalPanel with a4j:include to create a wizard-like user experience for the user to enter a specific Line Item. The first time a user clicks on the ?link? to launch the wizard things work fine ? the user steps through the wizard, submits and the new Line Item is added to the Purchase Order form. However, when the user clicks on the link a second time, the wizard launches but displays the last ?included xhtml? that was previously displayed. I can understand this behavior. It seems that the wizard has ?memory?. My question is: how can I tell the wizard to use the .xhtml that was originally provided to it via viewId in the a4j:include? In other words, I want to tell the wizard to lose its memory and start afresh. I?ve tried several combinations of transient and keepTransient but haven?t had much luck.

                      All the forum posts I?ve seen talk about adding a separate button to ?reset? the wizard. I can do that. But that would make it very awkward for users ? click here to reset the wizard and then click here to launch it. Is there a nicer way to tell a modalPane/a4j:include combination that it should start afresh using the a4j:include viewId that it was originally provided?

                      • 10. Re: question about a4j:include and navigation rules
                        Vidur Dhanda Newbie

                        Hi,

                        I call the wizard by using <h:outputLink id="addDialogLink" value="javascript:Richfaces.showModalPanel('addDialog')">Add </h:outputLink>

                        An interesting observation. When I view the component tree via Facelets' debug capability, I see the first page's structure! And not the structure of the wizard page that is currently being displayed.

                        Thanks for helping me with this.

                        Regards,
                        Vidur

                        • 11. Re: question about a4j:include and navigation rules
                          Alexander Smirnov Master

                          Working sample for a your use-case:

                           <a4j:form id="mainForm">
                           <a4j:keepAlive beanName="navigateBean"/>
                           <h:outputText style="left: 570px; top: 50px; position: absolute; width:20%; font-weight: bold;" value="Main Page"/>
                           <a4j:include id="ajaxPanel" viewId="#{navigateBean.viewId}" />
                           <a4j:commandButton value="Reset" action="#{navigateBean.reset}" reRender="ajaxPanel" />
                           </a4j:form>
                          

                          Navigate bean ( request-scope ) :
                          .........
                          public class NavigateBean implements Serializable {
                          
                           private String viewId="/pages/hello.jsp";
                          
                           transient private UIInclude include;
                          
                           public String navigateOne() {
                          
                           return "sucessOne";
                           }
                          
                           public String navigateTwo() {
                          
                           return "sucessTwo";
                           }
                          
                           public String navigateHello() {
                          
                           return "sucessHello";
                           }
                          
                           /**
                           * @return the viewId
                           */
                           public String getViewId() {
                           return viewId;
                           }
                          
                           /**
                           * @param viewId the viewId to set
                           */
                           public void setViewId(String viewId) {
                           this.viewId = viewId;
                           }
                          
                           public String reset(){
                           setViewId("/pages/hello.jsp");
                           if(null != include){
                           include.setViewId("/pages/hello.jsp");
                           }
                           return null;
                           }
                          
                           /**
                           * @return the include
                           */
                           public UIInclude getInclude() {
                           return include;
                           }
                          
                           /**
                           * @param include the include to set
                           */
                           public void setInclude(UIInclude include) {
                           this.include = include;
                           }
                          .........
                          

                          With a same backing bean, via component binding :
                           <a4j:form id="mainForm">
                           <h:outputText style="left: 570px; top: 50px; position: absolute; width:20%; font-weight: bold;" value="Main Page"/>
                           <a4j:include id="ajaxPanel" viewId="/pages/hello.jsp" binding="#{navigateBean.include}"/>
                           <a4j:commandButton value="Reset" action="#{navigateBean.reset}" reRender="ajaxPanel" />
                           </a4j:form>
                          


                          • 12. Re: question about a4j:include and navigation rules
                            Vidur Dhanda Newbie

                            Hi,

                            Thanks for your post. I appreciate your help. Perhaps, this is more of a "how to" question. And please appreciate that I'm new to these technologies so my questions might seem "basic" or "obvious".

                            My challenge is to display the wizard in a rich:modalPanel. And I'm using Richfaces.showModalPanel to do that. If I understand the sample code correctly, then the user would have to first reset the wizard via the commandButton and then launch the wizard via a outputLink. Is it possible to combine the two UI interactions into a single UI interaction from the user's perspective?

                            Thanks,
                            Vidur

                            • 13. Re: question about a4j:include and navigation rules
                              Sergey Smirnov Master

                              h:outputLink is not required to launch the modal panel. You can do it from any place the you can invoke the javascript code.

                              in case of using a4j:commandButton, you can "reset" the wizard with the value of reRender attribute and then popup the modalPanel from the 'oncomplete' attribute.

                              The activities will be performed right in desire order.

                              • 14. Re: question about a4j:include and navigation rules
                                Vidur Dhanda Newbie

                                Thanks. That worked like a charm! Your suggestion of combining an action, reRender and oncomplete is very powerful and allows me to initialize a wizard to any state and launch it. A suggestion. Could we put this is the user guide?

                                Thanks for all your help.

                                Regards,
                                Vidur

                                1 2 Previous Next