1 Reply Latest reply on Apr 16, 2010 10:44 PM by purecharger

    JSF Composite Component

    purecharger

      I'm trying to create a composite component for use in my Seam application, and I'm running into problems with the simplest hello, world component.


      I have placed a file named hello.xhtml in {jboss deploy}/application.ear/application.war/resources/greet


      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:composite="http://java.sun.com/jsf/composite">
      <head>
      <title>My First Composite Component</title>
      </head>
      <body>
      
      <composite:interface>
          <composite:attribute name="who"/>
      </composite:interface>
      
      <composite:implementation>
          <h:outputText value="Hello, #{cc.attrs.who}!"/>
      </composite:implementation>
      
      </body>
      </html>



      Now in home.xhtml, located at the root of my webapp ({jboss deploy}/application.ear/application.war/home.xhtml):


      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                      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:g="http://java.sun.com/jsf/composite/greet"
                      xmlns:s="http://jboss.com/products/seam/taglib"
                      template="layout/template.xhtml">
          <ui:define name="content">
          <div id="content">
              <g:hello who="World"/>
              <br/>
          </div>
          </ui:define>
      </ui:composition>



      But my hello, world is not displayed. Any ideas?

        • 1. Re: JSF Composite Component
          purecharger

          I think I know why this does not work: Seam doesn't play well with JSF 2.0, even though, according to Dan Allen, Seam 2 and JSF 2.0 absolutely work together (http://seamframework.org/Documentation/DoesSeamWorkWithJSF2).


          faces-config.xml in seam-gen created projects and the seam examples all specify 1.2 as the version and use FacesViewHandler, a 1.2 class. Attempting to deploy an application with JSF 2.0 jars and specifying 2.0 in faces-config.xml causes this exception:


          2010-04-16 11:24:18,249 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (Thread-2) Unsanitized stacktrace from failed start...
          javax.faces.view.facelets.FaceletException: Must have a Constructor that takes in a ComponentConfig
               at com.sun.faces.facelets.tag.AbstractTagLibrary$UserComponentHandlerFactory.<init>(AbstractTagLibrary.java:289)
               at com.sun.faces.facelets.tag.AbstractTagLibrary.addComponent(AbstractTagLibrary.java:519)
          ...
          Caused by: java.lang.NoSuchMethodException: org.jboss.seam.ui.handler.CommandButtonParameterComponentHandler.<init>(javax.faces.view.facelets.ComponentConfig)
               at java.lang.Class.getConstructor0(Class.java:2706)
          



          I've filed a defect on JBoss JIRA:


          https://jira.jboss.org/jira/browse/JBSEAM-4637