2 Replies Latest reply on Dec 27, 2009 11:17 PM by verbalkint81

    Navigation Bug

    egoosen

      Hi Guys,


      I've just noticed a strange bug in my application wrt navigation.
      The navigation on a particular page doesn't work when I'm logged into my app, but it works fine when I'm not logged in.
      Here's my navigation rule in category.page.xml:



      <?xml version="1.0" encoding="UTF-8"?>
      <page xmlns="http://jboss.com/products/seam/pages"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.1.xsd">
      
           <param name="categoryId" value="#{categoryHome.categoryId}" />
           
           <navigation evaluate="#{categoryHome.childCategories}">
                <rule if-outcome="0">
                     <redirect view-id="/products.xhtml">
                          <param name="categoryId" value="#{categoryHome.categoryId}" />
                     </redirect>
                </rule>
           </navigation>
           <!--
           <navigation>
                <rule if="#{empty categoryHome.childCategories}">
                     <redirect view-id="/products.xhtml">
                          <param name="categoryId" value="#{categoryHome.categoryId}" />
                     </redirect>
                </rule>
           </navigation>
           this option below didn't work at all
      <navigation>
                <rule>
                     <redirect view-id="#{categoryHome.getViewId()}">
                          <param name="categoryId" value="#{categoryHome.categoryId}" />
                     </redirect>
                </rule>
           </navigation>
           -->
      
      </page>
      


      As you can see the one navigation rule is commented out, neither of them work when I'm logged in. Very strange?


      As a workaround I created a method on my CategoryHome object to return the view-id, but that didn't work either.


      I got this error:


      The page isn't redirecting properly


      Has anyone experienced this, and if so, how can I fix it, or what workaround can you suggest?


      Regards,
      Enrico




        • 1. Re: Navigation Bug
          egoosen

          Created this workaround in the mean time:


          <s:link action="#{categoryHome.getViewId()}" value="#{subCategory.name}">
               <f:param name="categoryId" value="#{subCategory.id}"/>
           </s:link>





          public String getViewId(){
                    if (getChildCategories().isEmpty()){
                         return "/products.xhtml";
                    } else {
                         return "/category.xhtml";
                    }
               }







          • 2. Re: Navigation Bug
            verbalkint81

            I have this workaround for you, which avoids having another component just for redirection purposes:


            <action execute="#{categoryHome.childCategories}" />
            <navigation>
                 <rule if-outcome="0">
                      <redirect view-id="/products.xhtml">
                           <param name="categoryId" value="#{categoryHome.categoryId}" />
                      </redirect>
                 </rule>
                    <!-- if-outcome is not 0 -->
                 <rule>
                      <!--do something else -->
                 </rule>
            </navigation>



            There is not much documentation on navigation in the official seam doc. It would seem like this would work but doesn't for me as well (I am using 2.1.1.GA):


            <navigation evaluate="#{categoryHome.childCategories}">
                 <rule if-outcome="0">
                      <redirect view-id="/products.xhtml">
                           <param name="categoryId" value="#{categoryHome.categoryId}" />
                      </redirect>
                 </rule>
            </navigation>



            Let me know if you find something better!