6 Replies Latest reply on Jun 21, 2007 7:15 AM by C B

    JSF Composition Components with Seam

    Valerij Timofeev Newbie

      I read this article http://www-128.ibm.com/developerworks/java/library/j-facelets/index.html and was excited about the possibility to compose quickly simple JSF components from source files:

      web.xml

      <context-param>
       <param-name>facelets.LIBRARIES</param-name>
       <param-value>
       /WEB-INF/facelets/tags/my.taglib.xml
       </param-value>
       </context-param>


      my.taglib.xml
      <facelet-taglib>
       <namespace>http://my.com/jsf</namespace>
       <tag>
       <tag-name>field</tag-name>
       <source>field.xhtml</source>
       </tag>
      </facelet-taglib>



      But it seems that the "field" component is simply ignored - it is not rendered. Web application (generated with seam-gen) is working. No errors in server.log

      Before I invest a lot of time into investigation, I'd like to ask Seam gurus whether it is possible in principle with all these ajax4jsf and/or seam view handlers?

      Thank you in advance

        • 1. Re: JSF Composition Components with Seam
          Fernando Montaño Expert

          Post the page where you are using the composition tag.

          • 2. Re: JSF Composition Components with Seam
            Fernando Montaño Expert

            And, also tell us where is located your field.xhtml?

            webapp/ ?
            webapp/WEB-INF?
            ...etc.

            • 3. Re: JSF Composition Components with Seam
              Valerij Timofeev Newbie

               

              "fernando_jmt" wrote:
              And, also tell us where is located your field.xhtml?

              webapp/ ?
              webapp/WEB-INF?
              ...etc.


              Thank you for the prompt reply.

              This is exactly the reason. I've placed taglib file and the component source into /WEB-INF/facelets/tags/my.taglib.xml (as you can see from my web.xml), but Seam deployment script ignores subdirectories in WEB-INF.

              I've moved both into WEB-INF and it works :-) !!!!

              Composition Components is a very powerfull feature I missed e.g. with Turbine + Velocity, not saying about PHP & Co. Now I can present our decision makers another strong argument for migration to Seam + JSF + Facelets.

              Post the page where you are using the composition tag.


              Before:
              ...
              <ui:composition xmlns="http://www.w3.org/1999/xhtml"
               xmlns:s="http://jboss.com/products/seam/taglib"
               xmlns:ui="http://java.sun.com/jsf/facelets"
               xmlns:f="http://java.sun.com/jsf/core"
               xmlns:h="http://java.sun.com/jsf/html"
               xmlns:rich="http://richfaces.ajax4jsf.org/rich"
               xmlns:my="http://my.com/jsf"
               template="layout/template.xhtml">
              ...
               <h:outputLabel for="username">Username</h:outputLabel>
               <h:inputText id="username"
               value="#{identity.username}"/>
               <h:outputLabel for="password">Password</h:outputLabel>
               <h:inputSecret id="password"
               value="#{identity.password}"/>
              ...


              After:
              ...
              <ui:composition xmlns="http://www.w3.org/1999/xhtml"
               xmlns:s="http://jboss.com/products/seam/taglib"
               xmlns:ui="http://java.sun.com/jsf/facelets"
               xmlns:f="http://java.sun.com/jsf/core"
               xmlns:h="http://java.sun.com/jsf/html"
               xmlns:rich="http://richfaces.ajax4jsf.org/rich"
               xmlns:my="http://my.com/jsf"
               template="layout/template.xhtml">
              ...
              <my:field label="Username" fieldName="username" entity="#{identity}" />
              <my:field label="Password" fieldName="password" entity="#{identity}" secret="true" />
              ...


              • 4. Re: JSF Composition Components with Seam
                Fernando Montaño Expert

                I have this in my web.xml:

                <context-param>
                 <param-name>facelets.LIBRARIES</param-name>
                 <param-value>
                 /WEB-INF/facelets/myapp.taglib.xml
                 </param-value>
                 </context-param>
                


                myapp.taglib.xml
                <?xml version="1.0"?>
                <!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>
                 <namespace>http://my.com/jsf/</namespace>
                 <tag>
                 <tag-name>dataScroller</tag-name>
                 <source>tags/dataScroller.xhtml</source>
                 </tag>
                </facelet-taglib>
                


                And in the dataScroller.xhtml is located: WEB-INF/facelets/tags/dataScroller.xhtml

                Then in my page (located anywhere) I have:
                <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                 xmlns:s="http://jboss.com/products/seam/taglib"
                 xmlns:ui="http://java.sun.com/jsf/facelets"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:h="http://java.sun.com/jsf/html"
                 xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
                 xmlns:rich="http://richfaces.ajax4jsf.org/rich"
                 xmlns:app="http://my.com/jsf"
                 template="/layout/template.xhtml">
                
                ....
                <app:dataScroller dataTableId="userListId"/>
                
                ....
                
                </ui:composition>
                
                



                And all is working OK.

                HTH.


                • 5. Re: JSF Composition Components with Seam
                  Valerij Timofeev Newbie

                   

                  "fernando_jmt" wrote:
                  I have this in my web.xml:

                  <context-param>
                   <param-name>facelets.LIBRARIES</param-name>
                   <param-value>
                   /WEB-INF/facelets/myapp.taglib.xml
                   </param-value>
                   </context-param>
                  


                  ...


                  Finally I moved all my component stuff into /view/component/ and everything works as well :-)

                  <context-param>
                   <param-name>facelets.LIBRARIES</param-name>
                   <param-value>
                   /component/myapp.taglib.xml
                   </param-value>
                   </context-param>
                  


                  • 6. Re: JSF Composition Components with Seam
                    C B Newbie

                    I think it should work in any subfolder of WEB-INF. But you might have to adapt your build.xml (if you use ant) in order to ensure that the files are actually packaged into the .war file! Just have a look at the exploded-archives and ensure that your files are deployed in the correct location.