13 Replies Latest reply on Oct 8, 2010 7:33 AM by bemar

    Step By Step How to use Apache Tomahawk Tags in your Seam Facelets Application.

    dhinojosa

      So I see a lot of people here really trying to reinvent a lot of wheels here. You don't have to redo a lot of validators,converters,ui tags because there are some that have already been created.  One such library is the Tomahawk library which was originally developed for the MyFaces JSF implementation. 


      To get this going for your application is simple.



      1. Download the latest Tomahawk

      2. Copy tomahawk-xxx.jar from your unpackaged download (located in the lib directory) to the your jboss-seam application's lib directory.

      3. Download the latest Tomahawk Facelets implementation from Google Code .  This is a library dedicated to making all of tomahawks components available for facelets.

      4. Copy tomahawk-facelets-taglib.jar from your unpackaged download into jboss-seam application's lib directory.

      5. Check your lib directory to see if you have commons-el.jar. If you don't download Commons EL from Apache Commons.

      6. Copy commons-el.jar from your unpackaged download to the your jboss-seam application's lib directory.

      7. Add the tomahawk-xxx.jar, tomahawk-facelets-taglib.jar, and commons-el.jar in your ant build under the war target (See Figure 1).

      8. Now you can use tomahawk in your pages. Just be sure to add tomahawk as a xml namespace in your header to use the tags. (See Figure 2).

      9. Call a special someone over, open up some champagne, and let the fireworks begin. WHACKA-OW!



      Figure 1


      <target name="war" depends="compile"
                  description="Build the distribution .war file">
              <copy todir="${war.dir}">
                  <fileset dir="${basedir}/view"/>
              </copy>
              <copy todir="${war.dir}/WEB-INF">
                  <fileset dir="${basedir}/resources/WEB-INF">
                      <include name="*.*"/>
                      <include name="classes/**/*.*"/>
                      <exclude name="classes/**/*.class"/>
                  </fileset>
                  <filterset>
                      <filter token="debug" value="${debug}"/>
                      <filter token="jndiPattern" value="${project.name}/#{ejbName}/local"/>
                  </filterset>
              </copy>
              <copy todir="${war.dir}/WEB-INF">
                  <fileset dir="${basedir}/resources/WEB-INF">
                      <include name="lib/*.*"/>
                      <include name="classes/**/*.class"/>
                  </fileset>
              </copy>
              <copy todir="${war.dir}/WEB-INF/lib">
                  <fileset dir="${lib.dir}">
                      <include name="richfaces-impl*.jar"/>
                      <include name="richfaces-ui*.jar"/>
                      <include name="oscache*.jar"/>
                      <include name="commons-digester.jar"/>
                      <include name="commons-beanutils.jar"/>
                      <include name="jsf-facelets.jar"/>
                      <include name="jboss-seam-*.jar"/>
                      <exclude name="jboss-seam-gen.jar"/>  
                      <include name="tomahawk-1.1.6.jar"/> <!--ADDED-->
                      <include name="tomahawk-facelets-taglib.jar"/> <!--ADDED-->
                      <include name="commons-el.jar"/> <!--ADDED-->
                  </fileset>
              </copy>
              <copy todir="${war.dir}/WEB-INF/classes">
                  <fileset dir="${basedir}/resources">
                      <include name="messages*.properties"/>
                  </fileset>
              </copy>
          </target>
      
      



      Figure 2


      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:s="http://jboss.com/products/seam/taglib"
            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:ui="http://java.sun.com/jsf/facelets"
            xmlns:t="http://myfaces.apache.org/tomahawk"   
            xml:lang="en"
            lang="en">  <!--NOTICE THIS HEADER HAS CHANGED AND NOW CONTAINS XMLNS:T -->
      <head>
          <title>User subform</title>
      </head>
      <body>
      <ui:composition>
          <h:panelGrid columns="2">
              <h:outputLabel value="Email Address (used as login)" for="lastName"/>
              <h:panelGroup>
                  <h:inputText value="#{user.emailAddress}"
                               id="emailAddress" required="true" size="50"/>
                  <h:message for="emailAddress"/>
              </h:panelGroup>
      
              <h:outputLabel value="First Name" for="firstName"/>
              <h:panelGroup>
                  <h:inputText value="#{user.firstName}"
                               id="firstName" required="true" size="50"/>
                  <h:message for="firstName"/>
              </h:panelGroup>
      
              <h:outputLabel value="Last Name" for="lastName"/>
              <h:panelGroup>
                  <h:inputText value="#{user.lastName}"
                               id="lastName" required="true" size="50"/>
                  <h:message for="lastName"/>
              </h:panelGroup>
      
              <h:outputLabel value="Password" for="password"/>
              <h:panelGroup>
                  <h:inputSecret value="#{user.password}"
                                 id="password" required="true" size="50"/>
                  <h:message for="password"/>
              </h:panelGroup>
      
              <h:outputLabel value="Password Match" for="passwordMatch"/>
              <h:panelGroup>
                  <h:inputSecret value=""
                                 id="passwordMatch" required="true" size="50">
                      <t:validateEqual for="password"/>  <!==WANT TO MAKE SURE PASSWORDS MATCH? TRY THIS TAG! EASY!-->
                  </h:inputSecret>
                  <h:message for="passwordMatch"/>
              </h:panelGroup>
          </h:panelGrid>
      </ui:composition>
      </body>
      </html>
      



        • 1. Re: Step By Step How to use Apache Tomahawk Tags in your Seam Facelets Application.
          www.supernovasoftware.com

          I remember back in the old days before Richfaces, the Seam team did not recommend using Tomahawk.


          I was using it, but after I integrated Trinidad and Richfaces I totally removed it from my app.


          What are the current recommendations from the core Seam developers?

          • 2. Re: Step By Step How to use Apache Tomahawk Tags in your Seam Facelets Application.
            marx3

            How Tomahawk compares to RichFaces? Is it more powerfull? Or is it less buggy? Or is it faster? or has it better Ajax support?

            • 3. Re: Step By Step How to use Apache Tomahawk Tags in your Seam Facelets Application.
              admin.admin.email.tld

              post to the knowledge base if you haven't already...

              • 4. Re: Step By Step How to use Apache Tomahawk Tags in your Seam Facelets Application.
                dhinojosa

                Neither of those.  They seem only to have the specialized tags that you need once in a while.  Take a look at the catalog.

                • 5. Re: Step By Step How to use Apache Tomahawk Tags in your Seam Facelets Application.
                  amitev

                  Tomahawk is out of date and hardly supported

                  • 6. Re: Step By Step How to use Apache Tomahawk Tags in your Seam Facelets Application.
                    vojeda

                    Dan,


                      with your tips I tried to use the schedule component without luck. Can you be kind enough to show me your ear structure (where are the tomahawk library, how is your web.xml and so on)


                    Thanks in advance


                    Best regards,


                      Victor


                    PD: if anybody used the Tomahawk components in a portal, I appreciate to know about that

                    • 7. Re: Step By Step How to use Apache Tomahawk Tags in your Seam Facelets Application.
                      dhinojosa

                      Hi Victor I use seam-gen. So, whatever ear seam-gen creates is the same as I have. ;)

                      • 8. Re: Step By Step How to use Apache Tomahawk Tags in your Seam Facelets Application.
                        dhinojosa

                        It doesn't mention that on their website.

                        • 9. Re: Step By Step How to use Apache Tomahawk Tags in your Seam Facelets Application.
                          taccart.thierry.accart.name

                          Hi Daniel


                          Thanks for the informations : I was looking for a solution like tomahawk's schedule, and with your post, I'll try to use it.


                          For the moment, I've a nice exception when trying to get t:schedule working (seems weird because  the validateEqual seemed okay...)


                          If ever somebody has an idea : I'm posting the stack trace like a bottle in the ocean :-)



                          ERROR [STDERR] 6 juil. 2008 22:15:13 com.sun.facelets.FaceletViewHandler handleRenderException
                          GRAVE: Error Rendering View[/tomatest.xhtml]
                          java.lang.IllegalStateException: ExtensionsFilter not correctly configured. JSF mapping missing. JSF pages not covered. Please see: http://myfaces.apache.org/tomahawk/extensionsFilter.html
                               at org.apache.myfaces.renderkit.html.util.AddResourceFactory.throwExtensionsFilterMissing(AddResourceFactory.java:358)
                               at org.apache.myfaces.renderkit.html.util.AddResourceFactory.checkEnvironment(AddResourceFactory.java:318)
                               at org.apache.myfaces.renderkit.html.util.AddResourceFactory.getInstance(AddResourceFactory.java:273)
                               at org.apache.myfaces.custom.schedule.renderer.AbstractScheduleRenderer.encodeBegin(AbstractScheduleRenderer.java:157)
                               at org.apache.myfaces.custom.schedule.renderer.ScheduleDetailedDayRenderer.encodeBegin(ScheduleDetailedDayRenderer.java:73)
                               at org.apache.myfaces.custom.schedule.renderer.ScheduleDelegatingRenderer.encodeBegin(ScheduleDelegatingRenderer.java:70)
                               at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:788)
                               at javax.faces.component.UIComponent.encodeAll(UIComponent.java:884)
                               at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
                               at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
                               at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
                               at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
                               at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
                               at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                               at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
                               at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
                               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                               at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
                               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                               at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
                               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                               at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                               at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                               at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
                               at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
                               at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
                               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                               at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
                               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                               at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                               at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                               at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                               at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                               at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
                               at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                               at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                               at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                               at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                               at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                               at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                               at java.lang.Thread.run(Unknown Source)
                          


                          • 10. Re: Step By Step How to use Apache Tomahawk Tags in your Seam Facelets Application.
                            jfquest

                            Visit the page http://myfaces.apache.org/tomahawk/extensionsFilter.html that explains how to configure tomahawk library in web.xml

                            • 11. Re: Step By Step How to use Apache Tomahawk Tags in your Seam Facelets Application.
                              bcowdery.bcowdery.gmail.com

                              Tried this using Seam 2.1.1.GA, Tomahawk 1.1.8 and Tomahawk facelets 1.1.6.2 on JBoss AS 4.2.2.GA


                              Tomahawk components have some major issues finding components by id, when i tried using the <t:validateEquals> validator I got the following exception:


                              javax.faces.FacesException: Unable to find component 'newPassword' (calling findComponent on component 'verifiedPassword')
                                   at org.apache.myfaces.custom.equalvalidator.EqualValidator.validate(EqualValidator.java:72)
                                   at javax.faces.component.UIInput.validateValue(UIInput.java:1013)
                                   at javax.faces.component.UIInput.validate(UIInput.java:867)
                                   at javax.faces.component.UIInput.executeValidate(UIInput.java:1065)
                                   at javax.faces.component.UIInput.processValidators(UIInput.java:666)
                                   at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1033)
                                   at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1033)
                                   at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1033)
                                   at org.ajax4jsf.component.UIAjaxRegion.processValidators(UIAjaxRegion.java:125)
                                   at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1033)
                                   at org.richfaces.component.UISwitchablePanel.processValidators(UISwitchablePanel.java:236)
                                   at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1033)
                                   at javax.faces.component.UIForm.processValidators(UIForm.java:229)
                                   at org.ajax4jsf.component.AjaxViewRoot$3.invokeContextCallback(AjaxViewRoot.java:439)
                                   at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:238)
                                   at org.ajax4jsf.component.AjaxViewRoot.processValidators(AjaxViewRoot.java:455)
                                   at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:100)
                                   at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                                   at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
                                   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
                                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                                   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                                   at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
                                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                                   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
                                   at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                                   at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                                   at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                                   at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                                   at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
                                   at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
                                   at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
                                   at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
                                   at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                                   at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
                                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                                   at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
                                   at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                                   at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                                   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                                   at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                                   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                                   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                                   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                                   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                                   at org.jboss.web.tomcat.service.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:87)
                                   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
                                   at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                                   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                                   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                                   at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                                   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                                   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                                   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                                   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                                   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                                   at java.lang.Thread.run(Thread.java:595)
                              



                              Tomahawk's own extended input elements don't fair any better (<t:inputSecret>) with the validator. There are some old bug reports referencing this issue and they state you can use forceId as a workaround - but that didn't work either. I suspect it may be a JSF RI bug, but unfortunately I don't have time to investigate further...



                              For those that are interested, here's the relevant chunk from my xhtml page:



                              <s:decorate id="newPasswordDecorator" template="../layout/edit.xhtml">
                                  <ui:define name="label">New Password</ui:define>
                                  <t:inputSecret id="newPassword"
                                                 value="#{userProfileHome.newPassword}"
                                                 forceId="true">
                                  </t:inputSecret>
                              </s:decorate>
                              
                              <s:decorate id="verifiedPasswordDecorator" template="../layout/edit.xhtml">
                                  <ui:define name="label">Confirm Password</ui:define>
                                  <t:inputSecret id="verifiedPassword"
                                                 value="#{userProfileHome.verifiedPassword}"                                           
                                                 forceId="true">
                                      <t:validateEqual for="newPassword"/>
                                  </t:inputSecret>
                              </s:decorate>






                              It's a pitty, this would have saved me lots of time :P

                              • 12. Re: Step By Step How to use Apache Tomahawk Tags in your Seam Facelets Application.
                                bcowdery.bcowdery.gmail.com

                                Arg... Turns out my above post is a Seam problem (JBSEAM-3676 https://jira.jboss.org/jira/browse/JBSEAM-3676), where the s:decorate throws off component lookups because it is a NamingContainer. The bug has been fixed in Seam 2.1.2.CR, but some people still may bump into this issue with older versions.


                                The workaround here is to specify an absolute search path for your component id. So my above example would work for



                                <t:validateEqual for=":user-profile:newPasswordDecorator:newPassword"/>
                                




                                An absolute search path should start with the separator character : and contain any NamingContainers that may be between the view root and the target UIComponent. UIComponent searches (via component.findComponent()) will search up through the parent components, or down through the children components until it encounters a NamingContainer - which means if you have a realative search path and a NamingContainer anywhere between the the starting search point and the target component it will never find your target component.



                                so if your using s:decorate make sure you use an absolute path...

                                • 13. Re: Step By Step How to use Apache Tomahawk Tags in your Seam Facelets Application.
                                  bemar

                                  Any news for that issue?
                                  I've implemented commons-el and tomahawk for jsf 1.2. No errors while starting up but I've got the error that the website is redirecting to a infinite loop.
                                  In the console there is no error.


                                  Do anyone know what the error could be?


                                  Thx


                                  Ben