8 Replies Latest reply on Feb 24, 2007 5:21 AM by Ben Catherall

    custom JSF component with facelets

    David G. Newbie

      Hi, all!

      I am trying to run my JSF custom component with facelets. Is it necessary to reference de XX.taglib.xml from web.xml with this code?:

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


      because JBoss Seam doesn't need this context-param (Tomahawk yes). How can I avoid this parameter?. I have been looking the JBoss Seam UI source code, and seam.taglib.xml is located at META-INF.
      If I put my XX.taglib.xml there, my tag isn't executed, but rendered as plain text.

      Thanks in advance!

        • 1. Re: custom JSF component with facelets
          Pete Muir Master

          It shouldn't be, no.

          Put it in META-INF/ if you are putting the facelets in a jar included in WEB-INF/lib. Put it in WEB-INF if you are just putting the facelets straight into your war.

          BTW I never needed that parameter for tomahawk if I put the tomahawk.taglib.xml in WEB-INF (or a sub directory).

          • 2. Re: custom JSF component with facelets
            David G. Newbie

            OK, if i move the tomahawk.taglib.xml to tomahawk.jar!META-INF , it works, but with my tags this doesn't work :( any idea?

            My my.jar!META-INF content:
            taglib.tld (tags for MyFaces without facelets, for example).
            faces-config.xml (the JSF components).
            nt.taglib.xml (the link between the component-type and the component-class, the facelets)

            Thanks for your help petemuir

            • 3. Re: custom JSF component with facelets
              Pete Muir Master

              You should see log messages when you access your first facelets page

              13:20:37,850 ERROR [STDERR] 04-Dec-2006 13:20:37 com.sun.facelets.compiler.TagLibraryConfig loadImplicit
              INFO: Added Library from: jar:file:/Z:/jboss/jboss-4.0.5.GA/server/default/./deploy/spm-seam.ear/spm-seam.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-core.taglib.xml


              for all the tag libraries facelets can load (for the entire app). If your nt.taglibrary.xml isn't mentioned please post your war structure.

              If it is then you've probably got a namespace typo between nt.taglib.xml and your facelet.

              • 4. Re: custom JSF component with facelets
                David G. Newbie

                This is the structure of the jar under my /WEB-INF/lib/:

                META-INF:
                - faces-config.xml
                - nt.taglib.xml
                - taglib.tld
                and the packets structure containing my tags and JSF components.

                My tags work only if I specify facelets.LIBRARIES option under web.xml.

                faces-config.xml:

                <?xml version="1.0" encoding="UTF-8"?>
                <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
                 "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
                <faces-config>
                
                 <component>
                 <component-type>component.Version</component-type>
                 <component-class>component.Version</component-class>
                 </component>
                </faces-config>
                


                nt.taglib.xml:
                <?xml version="1.0"?>
                <!DOCTYPE facelet-taglib PUBLIC
                 "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
                 "facelet-taglib_1_0.dtd">
                
                <facelet-taglib>
                
                 <namespace>http://www.ntrying.com</namespace>
                
                 <tag>
                 <tag-name>version</tag-name>
                 <component>
                 <component-type>component.Version</component-type>
                 </component>
                 </tag>
                
                
                </facelet-taglib>
                


                taglib.tld:
                <?xml version="1.0"?>
                <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
                 "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
                <taglib>
                
                 <tlib-version>1.0</tlib-version>
                 <jsp-version>1.2</jsp-version>
                 <short-name>nt</short-name>
                 <uri>http://www.ntrying.com</uri>
                 <display-name>NTrying.com.</display-name>
                
                 <!-- <nt:version /> -->
                 <tag>
                 <name>version</name>
                 <tag-class>taglib.VersionTag</tag-class>
                 <body-content>empty</body-content>
                 <description>
                 The current version of the Ntrying library.
                 </description>
                 </tag>
                </taglib>
                


                • 5. Re: custom JSF component with facelets
                  Pete Muir Master

                  I'm not sure then, I suggest you ask on the facelets list.

                  https://facelets.dev.java.net

                  • 7. Re: custom JSF component with facelets
                    Frank Fischer Newbie

                     

                    "dgallego" wrote:
                    Thanks!


                    Did you ever find a solution for this problem? I have the exact same situation.

                    Regards,

                    Frank

                    • 8. Re: custom JSF component with facelets
                      Ben Catherall Newbie

                      I think you have to specify it in web.xml if you do not package your library in to its own jar file?