7 Replies Latest reply on May 14, 2008 3:26 PM by Vikram Chhetry

    Ajax include problem

    Vikram Chhetry Newbie

      Hi All,
      I am using richfaces ajax include inside a modalPanel.
      It works fine but with one problem.


      I have a wizard pattern to submit user details. When I close the modalPanel somewhere in between of the wizard the wizard loads from the same step when I start the wizard again.


      Ex:-


      Suppose I have a wizard of 4 steps.


      1---2---3---4


      I close the wizard in 3rd step without saving the details.


      Then I start the wizard again.


      It will load from 3rd step not from the 1st.


      Is there any way of resetting it to its initial step.


      Any help would be appreciated.


      Thanks & regards,


      -Vikram


        • 1. Re: Ajax include problem
          James Kelly Newbie

          Can you post some code? E.g. how you're starting the wizard and what your navigation rules look like...

          • 2. Re: Ajax include problem
            Damian Harvey Apprentice

            That makes sense.


            You page has loaded the included page for step 3. When you open the wizard again the included page 3 will remain in the DOM unless you tell the page to reload the included page 1.


            On the button/link that opens the wizard make sure that you are reRendering the include. Also you may want to have that button call a navigation action that loads page 1 every time it is clicked and have that navigation action available from all included pages (1-4).


            Cheers,


            Damian.

            • 3. Re: Ajax include problem
              Vikram Chhetry Newbie

              On the button/link that opens the wizard make sure that you are reRendering the include.

              I understand this one.



              Also you may want to have that button call a navigation action that loads page 1 every time it is clicked and have that navigation action available from all included pages (1-4).

              I am not able understand this thing.


              I have an button which goes to my session bean and fetches some data and on complete it opens the modalPanel which contains the navigation 1st step.


              Could you please explain me with an example?


              Thanks a lot for your reply.


              Vikram

              • 4. Re: Ajax include problem
                Damian Harvey Apprentice

                On the second point, all I'm saying is that each included page needs to have a pages.xml entry (or it's own xxx.page.xml) and the navigation steps should be in each one.


                Try doing something simple before jumping right into a modal wizard. Get a simple page working first eg


                Main page:


                     <h:form>
                          <rich:panel id="wizardPanel">
                               <a:include viewId="/test/testWizardPage1.xhtml"/>
                          </rich:panel>
                     </h:form>
                



                Page1.xhtml:
                     


                <s:div id="page1" style="width:400px;height:400px; background-color:red;">
                          hello this is page 1
                     </s:div>
                     <a:commandLink action="#{testWizardBean.testAction}" reRender="wizardPanel" value="Next"/>
                
                


                Page1.page.xml:


                     <navigation>
                          <rule if-outcome="next">
                               <render view-id="/test/Page2.xhtml"/>
                          </rule>
                     </navigation>
                


                Page2.xhtml:


                     <s:div style="width:400px;height:400px; background-color:green;">
                          hello this is page 2
                     </s:div>
                     <a:commandButton action="previous" reRender="wizardPanel" value="Previous"/>
                     <a:commandButton action="done" reRender="wizardPanel" value="Done"/>
                



                Page2.page.xml:


                     <navigation>
                          <rule if-outcome="previous">
                               <render view-id="/test/Page1.xhtml"/>
                          </rule>
                          <rule if-outcome="done">
                               <render view-id="/test/Page3.xhtml"/>
                          </rule>
                     </navigation>
                
                



                Page3.xhtml:


                     <s:div style="width:400px;height:400px; background-color:yellow;">
                          DONE
                     </s:div>
                
                


                Cheers,


                Damian.


                • 5. Re: Ajax include problem
                  Vikram Chhetry Newbie

                  Thanks Damian,


                  I had already done this except reRendering. Now I have added reRender in all the buttons but still its not working(same problem).


                  Thanks,


                  Vikram

                  • 6. Re: Ajax include problem
                    Damian Harvey Apprentice

                    How about posting a simple 2 page example that shows your problem then? If it's small I'm sure we can easily find the solution.


                    Note: one difference from 'normal' pages.xml navigation is the use of render rather than redirect. Which one are you using?


                    Cheers,


                    Damian.

                    • 7. Re: Ajax include problem
                      Vikram Chhetry Newbie

                      I am sorry, my mapping is in faces-config.xml


                      <navigation-rule>
                      <from-view-id>page1.xhtml</from-view-id>
                      <navigation-case>
                      <from-outcome>next</from-outcome>
                      <to-view-id>page2.xhtml</to-view-id>
                      </navigation-case>
                      </navigation-rule>
                      



                      can we something like this??



                      action="'#{myBean.myFunction}','next'"



                      might be a weired question.


                      Thanks,


                      Vikram