6 Replies Latest reply on Jan 4, 2008 11:49 AM by parki

    Illegal view ID error in navigation rule

    parki

      Hello:

      First off, kudos to the developers - RichFaces is some pretty sweet stuff.

      I'm running into one error (see below for full trace).

      I'm setting up authorization stuff (based in part on the examples in Kito Mann's book). Everything works fine, with the following setup:

      /web
       - ecobee.xhtml
       - login.xhtml
       - /WEB-INF
       - faces-config.xml
       - web.xml
       - /xhtml
       - foo.xhtml
       - bar.xhtml
      


      web.xml:

      <filter-mapping>
       <filter-name>AuthorizationFilter</filter-name>
       <url-pattern>/ecobee.jsf</url-pattern>
      </filter-mapping>
      


      faces-config.xml:

       <navigation-rule>
       <from-view-id>/login.xhtml</from-view-id>
       <navigation-case>
       <from-outcome>success</from-outcome>
       <to-view-id>/ecobee.xhtml</to-view-id>
       <redirect />
       </navigation-case>
       <navigation-case>
       <from-outcome>failure</from-outcome>
       <to-view-id>/login.xhtml</to-view-id>
       <redirect />
       </navigation-case>
       </navigation-rule>


      I'd like to move the 'ecobee.xhtml' file into the 'web/xhtml' directory, and change the authorization filter rule from the specific 'ecobee.jsf' file to filter on any file in the 'xhtml' directory. The changes:

      web.xml:

      <filter-mapping>
       <filter-name>AuthorizationFilter</filter-name>
       <url-pattern>/xhtml/*</url-pattern>
      </filter-mapping>
      


      and faces-config.xml:

       <navigation-rule>
       <from-view-id>/login.xhtml</from-view-id>
       <navigation-case>
       <from-outcome>success</from-outcome>
       <to-view-id>/xhtml/ecobee.xhtml</to-view-id>
       <redirect />
       </navigation-case>
       <navigation-case>
       <from-outcome>failure</from-outcome>
       <to-view-id>/login.xhtml</to-view-id>
       <redirect />
       </navigation-case>
       </navigation-rule>


      When I attempt this, I get an error (see below) which complains about an illegal view id - seems that the 'to-view-id' with value '/xhtml/ecobee.xhtml' doesn't work right.

      I'm a little stumped - tried a few things, but I can't seem to be able to move the 'ecobee.xhtml' file from '/web' to 'web/xhtml' and have the authorization stuff still work.

      Can anyone shed any light on this?

      Many thanks - appreciated,

      parki...

      javax.servlet.ServletException: Illegal view ID .xhtml/ecobee.xhtml. The ID must begin with /
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
       org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
       org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
       com.ecobee.webapp.servlet.AuthorizationFilter.doFilter(AuthorizationFilter.java:60)
      
      root cause
      
      java.lang.IllegalArgumentException: Illegal view ID .xhtml/ecobee.xhtml. The ID must begin with /
       com.sun.faces.application.ViewHandlerImpl.getActionURL(ViewHandlerImpl.java:627)
       com.sun.facelets.FaceletViewHandler.getActionURL(FaceletViewHandler.java:781)
       com.sun.facelets.FaceletViewHandler.handleFaceletNotFound(FaceletViewHandler.java:686)
       com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:637)
       org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
       com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
       com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
       com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
       org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
       org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
       com.ecobee.webapp.servlet.AuthorizationFilter.doFilter(AuthorizationFilter.java:60)
      


        • 1. Re: Illegal view ID error in navigation rule

          Does Kito Mann' say that this filter must come first if other filters exist?

          • 2. Re: Illegal view ID error in navigation rule
            parki

            Hi Sergey:

            Did more investigation - this problem is not related to the filter - I've removed it and still get the error - the problem is related to the navigation rule.

            To recap, if the 'ecobee.xhtml' file located in the 'web' directory, then things work fine with the following navigation rule:

            <navigation-rule>
             <from-view-id>/login.xhtml</from-view-id>
             <navigation-case>
             <from-outcome>success</from-outcome>
             <to-view-id>/ecobee.xhtml</to-view-id>
             <redirect />
             </navigation-case>
             <navigation-case>
             <from-outcome>failure</from-outcome>
             <to-view-id>/login.xhtml</to-view-id>
             <redirect />
             </navigation-case>
             </navigation-rule>


            If I move the 'ecobee.xhtml' file to the 'web/xhtml' directory, and change the navigation rule to read:

            <navigation-rule>
             <from-view-id>/login.xhtml</from-view-id>
             <navigation-case>
             <from-outcome>success</from-outcome>
             <to-view-id>/xhtml/ecobee.xhtml</to-view-id>
             <redirect />
             </navigation-case>
             <navigation-case>
             <from-outcome>failure</from-outcome>
             <to-view-id>/login.xhtml</to-view-id>
             <redirect />
             </navigation-case>
             </navigation-rule>


            then I get the exception.

            The only changes being made is the location of the 'ecobee.xhtml' file, and the value of 'to-view-id' in the success navigation case.

            Is this a facelets thing?

            Any and all help appreciated - it's a little thing, but annoying. :) :)

            Cheers,

            parki...




            • 3. Re: Illegal view ID error in navigation rule

              you say 'web/xhtml', but have '/xhtml/ecobee.xhtml' in the rule. What the 'web' means in this context and how it related to the 'xhtml'?

              • 4. Re: Illegal view ID error in navigation rule
                parki

                Hi Sergey:

                Sorry - doing a poor job of explaining this (the reference to the 'web' directory is slightly misleading, as this is in the dev repo, not the resulting war file).

                So, I'll only consider the file structure in the exploded war file.

                Things work when the 'ecobee.xhtml' file is contained at the top level of the directory structure. When the 'to-view-id' is set to '/ecobee.xhtml' in the navigation rule, everything works with directory structure:

                /ecobee
                 - ecobee.xhtml
                 - login.xhtml
                 - index.jsp
                 - /WEB-INF
                 - web.xml
                 - faces-config.xml
                 - /META-INF
                 etc.


                The problem is when I try to put the ecobee.xhtml file into a subdirectory (called xhtml):

                /ecobee
                 - /xhtml
                 - ecobee.xhtml
                 - login.xhtml
                 - index.jsp
                 - /WEB-INF
                 - web.xml
                 - faces-config.xml
                 - /META-INF
                 etc.


                In other words, when I move the 'ecobee.xhtml' file into the 'xhtml' directory, and change the navigation rule 'to-view-id' from '/ecobee.xhtml' to '/xhtml/ecobee.xhtml' (with no other change), it results in the exception shown in the first message.

                Hope this helps (and thanks).

                parki...






                • 5. Re: Illegal view ID error in navigation rule

                  what if you actually rename it to 'web', instead of 'xhtml' ?

                  • 6. Re: Illegal view ID error in navigation rule
                    parki

                    Hi Sergey:

                    Know you're busy, so in short, things are now working - many thanks for your help - the support in this forum is very much appreciated.

                    I took your advice, and changed the name of the subdirectory from 'xhtml' to 'web', and still ran into the same issues.

                    So then I did what seems to always work - go back to the demo application and start from there. So I renamed my 'xhtml' directory to 'richfaces' and structured the files in the same manner as the demo app.

                    With some resulting changes to 'web.xml' and 'faces-config.xml', it just started to work correctly.

                    So, I don't know exactly what step made the exception go away, but things are working now, so all is happiness.

                    Thanks.

                    parki...