7 Replies Latest reply on Oct 17, 2007 6:11 AM by shooali

    a4j:include, navigating out of the wizard

    shooali Newbie

      Hi,

      I have implemented a wizard using the a4j:include tag. navigating inside the wizard works great, I am using a4j:commandButton for that. However, I want to have a cancel button to navigate out the wizard, so I am using h:commandButton which I thought should work like always, but when clicking the button I get a FileNotfound exception that the jsf file could not be found in the external context as a Resource. It seems like the h:comandButton works the same as the a4j:commandbutton.
      What am I doing wrong?

      thanks,

        • 1. Re: a4j:include, navigating out of the wizard
          shooali Newbie

          I am attaching a code example:

          main page out.xhtml:

           <body>
           <ui:composition>
           <h:outputText value="walla sababa"/>
           <a4j:outputPanel id="wizard">
           <a4j:include viewId="/first.xhtml"/>
           </a4j:outputPanel>
           </ui:composition>
           </body>
          


          first page of wizard, first.xhtml:
           <ui:composition>
           <h:form id="formy">
           <a4j:commandButton id="next_btn" value="next" action="next" reRender="wizard"/>
           <h:commandButton id="cancel_btn" value="cancel" action="cancel"/>
           </h:form>
           </ui:composition>
          


          second page of the wizard, second.xhtml:
           <ui:composition>
           <h:form id="formy">
           <a4j:commandButton id="back_btn" value="back" action="back" reRender="wizard"/>
           <h:commandButton id="cancel_btn" value="cancel" action="cancel"/>
           </h:form>
           </ui:composition>
          


          navigation rules:
           <navigation-rule>
           <from-view-id>/first.xhtml</from-view-id>
           <navigation-case>
           <from-outcome>next</from-outcome>
           <to-view-id>/second.xhtml</to-view-id>
           </navigation-case>
           </navigation-rule>
           <navigation-rule>
           <from-view-id>/second.xhtml</from-view-id>
           <navigation-case>
           <from-outcome>back</from-outcome>
           <to-view-id>/first.xhtml</to-view-id>
           </navigation-case>
           </navigation-rule>
          
           <navigation-rule>
           <from-view-id>*</from-view-id>
           <navigation-case>
           <from-outcome>cancel</from-outcome>
           <to-view-id>/out.jsf</to-view-id>
           </navigation-case>
           </navigation-rule>
          


          clicking cancel will result in error:
          SEVERE: Error Rendering View[/out.xhtml]
          javax.faces.FacesException: UIInclude component j_id1 could't include page with path /out.jsf
           at org.ajax4jsf.taglib.html.facelets.IncludeHandler.applyNextHandler(IncludeHandler.java:83)
           at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:169)
          


          thanks

          • 2. Re: a4j:include, navigating out of the wizard
            Sergey Smirnov Master

            why you use /out.jsf instead of /out.xhtml ?

            • 3. Re: a4j:include, navigating out of the wizard
              shooali Newbie

              I use *.xhtml only for ajax (a4j:include) navigation. for regular JSF navigation I use *.jsf as the to-view-id(and it works). As I understood from the documents, if the action is not ajax (used h:commandButton) the navigation should be regular and for the whole page, not just the surrounding a4j:include tag. And in my example, I can see in the error that the problem is in the a4j:include tag that cannot find the out.jsf resource. why does it get to that include tag any way? and in case it should be like that (every action from withing the included viewid, using the a4j:include, will result in "a4j" navigation), how can I navigate out of the wizard?

              thanks,

              • 4. Re: a4j:include, navigating out of the wizard
                Ilya Shaikovsky Master

                you should use xhtml as always.

                • 5. Re: a4j:include, navigating out of the wizard
                  shooali Newbie

                  before using the a4j:include I have always used .jsf and it works fine. I really don't understand your answer. my problem is not .jsf or .xhtml. the problem is that I want to navigate out side of the wizard. Meaning, I want to have a button inside the wizard (inside a code that was included by the a4j:include) for example, in second.xhtml, that will navigate out of the wizard to a different page. the whole page.

                  It is written that every ajax action will trigger the a4j:include navigation, however, even regular h:commandButton does the same. thus I cannot get out of the wizard!!!!

                  • 6. Re: a4j:include, navigating out of the wizard
                    Sergey Smirnov Master

                    faces navigation rules point the the view-id . view-id is not an URL.

                    • 7. Re: a4j:include, navigating out of the wizard
                      shooali Newbie

                      I know that but what does it has to do with my question??
                      All I want is to navigate out of the wizard. In the a4j:include section in the docs, it is not clear that even if a non ajax action is performed it will result a navigation inside the a4j:include and not the whole page, even though it is a regular h:commandButton without reRender to the outputPanel surrounding the a4j:include and that outputPanel's ajaxRendered attribute is set to false!!!

                      The only way to get out of the wizard, is to put in the navigation rule.

                      Please update the docs to make it more clear to understand this.

                      Thanks a lot,