5 Replies Latest reply on Jun 5, 2008 12:26 PM by gonzalad

    Error using jsp syntax oriented pages with facelets (RF 3.1.

    gonzalad

      Hello,

      I've upgraded my app from RF 3.1.2.ga to RF 3.2.1.GA.

      I've the following error when using facelets (1.1.14) :

      /accueil.jspx @10,65 <jsp:directive.page> Tag Library supports namespace: http://java.sun.com/JSP/Page, but no tag was defined for name: directive.page


      I'm using a facelet page with a jsp oriented syntax :

      <?xml version="1.0" encoding="UTF-8" ?>
      <jsp:root xmlns="http://www.w3.org/1999/xhtml"
       xmlns:jsp="http://java.sun.com/JSP/Page"
       xmlns:c="http://java.sun.com/jstl/core"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:rich="http://richfaces.org/rich"
       xmlns:a4j="http://richfaces.org/a4j"
       version="2.0">
       <jsp:directive.page language="java"
       contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" />
      <f:view>
       <ui:composition template="#{theme.template}">
      
       <!-- content -->
       <ui:define name="content">
       <h:form id="loginForm">
      
       etc....
      
       </h:form>
       </ui:define>
       </ui:composition>
      </f:view>
      </jsp:root>


      When I remove the file META-INF/jsp.taglib.xml from richfaces-ui-3.2.1.GA.jar everything works fine.

      Is it a RF bug ?

      Thank you

        • 1. Re: Error using jsp syntax oriented pages with facelets (RF

          Did you see the result source code in the browser after you removed it?

          Facelets does not support JSP at all. It has own xhtml render kit. So, you page is incorrect from the very beginning. Facelets outputs the JSP tags as it to the result html.

          • 2. Re: Error using jsp syntax oriented pages with facelets (RF
            gonzalad

            Thanks for the answer Sergey,

            Facelets does not support JSP at all.

            -> You can put any directive in a facelet page (even jsp).
            You just have to put the unknown directive outside a ui:composition in order for facelet to ignore them.

            I think you should advice anyone using jsp syntax to put the jsp directives outside ui:composition, and just drop jsp.taglib.xml (but I'm perhaps missing something).

            My problem (short explanation) :
            Using RF 3.2.1.GA, when I use any jsp directive other than jsp:root in my facelet page it just break my facelet page.
            With previous versions everything worked fine (I've only needed to put jsp directives outside ui:composition element).

            My problem (full explanation) :
            1. So when, I remove jsp.taglib.xml from richfaces-ui-3.2.1.GA.jar [old behaviour of RF]:
            a. when I modify my facelets page to include the jsp directive *inside* the ui:composition [1], I can see the error
            XML Parsing Error: prefix not bound to a namespace
            Location: http://localhost:9080/aws/login.action?cid=8
            Line Number 55, Column 1:
            <jsp:root version="2.0">
            ^
            
            b. when I put the include directive *outside* the ui:composition [2], everything works fine (all my app function like that - I need jsp directove only
            for autocompletion in my ide, so I put these directoves outside the ui:composition).

            2. When I use the original richfaces-ui-3.2.1.GA.jar (with the jsp.taglib.xml)
            a. when I modify my facelets page to include the jsp directive *inside* [1], I have the following error :
            An Error Occurred:
            /login.jspx @17,65 <jsp:directive.page> Tag Library supports namespace: http://java.sun.com/JSP/Page, but no tag was defined for name: directive.page
            

            I must remove the <jsp:directive> in my page in order for my page to work.
            This is because jsp.taglib.xml is *incomplete*, it just defines jsp:root directive, but not every directive in the jsp spec.

            b. when I put the include directive *outside* the ui:composition [2], I have the same error :
            /login.jspx @12,65 <jsp:directive.page> Tag Library supports namespace: http://java.sun.com/JSP/Page, but no tag was defined for name: directive.page


            So, jsp.taglib.xml is incomplete.
            From my point of view, if you want to keep jsp.taglib.xml, it should be completed in a future release to include all jsp directives (ouch !).
            I've just modified jsp.taglib.xml for some test purposes and added directive.page element and all my pages work fine now.
            Another solution (I think it's the better one) is just to drop jsp.taglib.xml and just ask everyone using jsp xml syntax in their facelets page to include all jsp
            directives outside the ui:composition [3]. This also works very fine since facelets doesn't interpret the namespaces unknown (for which there's no taglib.xml).
            One last solution is to keep jsp.taglib.xml, but it should be worth documenting the limitation when using jsp syntax in facelets page (limitation : only jsp:root usage is
            allowed inside a facelet page).

            Thanks for your patience.

            [1]
            <?xml version="1.0" encoding="UTF-8" ?>
            <ui:composition xmlns="http://www.w3.org/1999/xhtml"
             xmlns:jsp="http://java.sun.com/JSP/Page"
             xmlns:c="http://java.sun.com/jstl/core"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:h="http://java.sun.com/jsf/html"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:s="http://jboss.com/products/seam/taglib"
             xmlns:rich="http://richfaces.org/rich"
             xmlns:a4j="http://richfaces.org/a4j"
             template="#{theme.template}">
            
             <ui:define name="content">
             <!-- JSP root *inside* ui:composition -->
             <jsp:root version="2.0">
             <jsp:directive.page language="java"
             contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" />
             <h:form id="loginForm">
            


            [2]
            <?xml version="1.0" encoding="UTF-8" ?>
            <!-- JSP root *outside* ui:composition, trimmed at runtime by facelets -->
            <jsp:root xmlns="http://www.w3.org/1999/xhtml"
             xmlns:jsp="http://java.sun.com/JSP/Page"
             xmlns:c="http://java.sun.com/jstl/core"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:h="http://java.sun.com/jsf/html"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:s="http://jboss.com/products/seam/taglib"
             xmlns:rich="http://richfaces.org/rich"
             xmlns:a4j="http://richfaces.org/a4j"
             version="2.0">
             <jsp:directive.page language="java"
             contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" />
            <f:view>
             <ui:composition template="#{theme.template}">
            
             <!-- content -->
             <ui:define name="content">
             <h:form id="loginForm">


            [3]
            As I understand one of the purposes of ui:composition [3] is just to improve facelets integration with any ide (you can put any header and footer needed
            by the ide for design or autocompletion purposes outside ui:composition), and facelets will just trim everything outside your ui:composition at runtime.
            see https://facelets.dev.java.net/nonav/docs/dev/docbook.html#template-composition

            [4] modified version of jsp.taglib.xml
            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE facelet-taglib PUBLIC
             "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
             "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
            <facelet-taglib xmlns="http://java.sun.com/JSF/Facelet">
             <namespace>http://java.sun.com/JSP/Page</namespace>
             <tag>
             <tag-name>root</tag-name>
             <handler-class>
             org.ajax4jsf.webapp.taglib.EmptyHandler
             </handler-class>
             </tag>
             <tag>
             <tag-name>directive.page</tag-name>
             <handler-class>
             org.ajax4jsf.webapp.taglib.EmptyHandler
             </handler-class>
             </tag>
            </facelet-taglib>


            • 3. jsp syntax pages with facelets (RF 3.1.2.GA)
              gonzalad

              I'm just removing any jsp:directive.page directive in my app.

              So, I won't have the pb anymore (for the moment).

              I think anyway, this issue should be solved.

              Thanks

              • 4. Re: Error using jsp syntax oriented pages with facelets (RF

                ask the question about supporting JSP tags in Faceslets on the Facelets Mailing List.

                • 5. Re: Error using jsp syntax oriented pages with facelets (RF
                  gonzalad

                  Thanks for your answer Sergey,

                  Ask the question about supporting JSP tags in Faceslets on the Facelets Mailing List.


                  Sorry, my thread was not about asking jsp tag support in facelets.

                  I was just asking if you can remove the file jsp.taglib.xml from RF distribution code, since it's not usefull from my point of view.

                  If someone needs to write jsp:root, just write it outside a ui:composition and facelets just ignores ( no need for jsp.taglib.xml) :
                  <?xml version="1.0" encoding="UTF-8" ?>
                  <jsp:root xmlns="http://www.w3.org/1999/xhtml"
                   xmlns:jsp="http://java.sun.com/JSP/Page"
                   xmlns:ui="http://java.sun.com/jsf/facelets"
                   xmlns:h="http://java.sun.com/jsf/html"
                   xmlns:f="http://java.sun.com/jsf/core" version="2.0">
                   <h:outputText value="test" />