You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
This article will describe how to create a Composite button that executes a method on a backing bean that is passed in from the custom tag.
See Creating Custom EL Functions as a starting point
Create another xml called META-INF/compositions.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://enhancements.seam/jsf</namespace>
<tag>
<tag-name>button</tag-name>
<source>../layout/enhancements/button.xhtml</source>
</tag>
</facelet-taglib>
Add that to your web.xml
<context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>
/META-INF/elfunctions.taglib.xml; compositions.taglib.xml
</param-value>
</context-param>
Create the button.xhtml in WebContent/layout/enhancements (JBDS) or view/layout/enhancements (seam-gen) :
<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:s="http://jboss.com/products/seam/taglib"
xmlns:rich="http://richfaces.org/rich"
xmlns:a="http://richfaces.org/a4j"
xmlns:c="http://java.sun.com/jstl/core">
<h:commandButton value="#{value}" action="#{backingBean[method]}" />
</ui:composition>
Create a Seam JavaBean we can play around with TestAction.java:
@Name("TestAction")
public class TestAction {
@Logger private Log log;
public void submit() {
log.info("TestAction:submit()");
}
}
Now in your view/ or WebContent/ folder create test.xhtml
<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.org/rich"
xmlns:custom="http://enhancements.seam/jsf"
template="layout/template.xhtml">
<ui:define name="body">
<h:form>
<custom:button value="Submit" backingBean="#{TestAction}" method="submit" />
</h:form>
</ui:define>
</ui:composition>
Navigate to test.seam, the output of clicking the button will be:
INFO [TestAction] TestAction:submit()