Java Reference
In-Depth Information
<h:outputLabel for="state" value="state"/>
<h:inputText id="state" value="#{cc.attrs.managedBean.
state}" size="2" maxlength="2"/>
<h:outputLabel for="zip" value="Zip"/>
<h:inputText id="zip" value="#{}"
size="5" maxlength="5"/>
We specify attributes for our component via the <cc:attribute> tag. This tag has a
name attribute used to specify the attribute name, and an optional required attribute
that we can use to specify if the attribute is required.
The body of the <cc:implementation> tag looks almost like plain old JSF markup,
with one exception, by convention, we can access the tag's attributes by using the
#{cc.attrs.ATTRIBUTE_NAME} expression to access the attributes we defined in
the component's interface section. Notice that the managedBean attribute of our
component must resolve to a JSF managed bean. Pages using our component must
use a JSF expression resolving to a managed bean as the value of this attribute.
We can access the attributes of this managed bean by simply using the familiar
.property notation we have used before, the only difference here is that instead of
using a managed bean name in the expression, we must use the attribute name as
defined in the interface section.
Now we have a simple but complete composite component, using it in our pages is
very simple.
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns=""
<title>Address Entry</title>
<h:panelGrid columns="1">
<ezcomp:address managedBean="#{addressBean}"
<h:commandButton value="Submit" action="confirmation"
style="display: block; margin: 0
Search WWH ::

Custom Search