Java Reference
In-Depth Information
<h:inputText id="line2"
<h:outputLabel for="city" value="City"/>
<h:inputText id="city" value="#{cc.attrs.namedBean.
<h:outputLabel for="state" value="state"/>
<h:inputText id="state" value="#{cc.attrs.namedBean.
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, which has a
name attribute used to specify the attribute name, and an optional required attribute
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 that we used to access the attributes we
defined in the component's interface section. Note that the namedBean attribute of
our component must resolve to a named bean. Pages using our component must
use a JSF expression resolving to a managed bean as the value of the namedBean
attribute. We can access the attributes of this named bean by simply using the
familiar dot ( . ) 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 that 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>
Search WWH ::

Custom Search