Java Reference
In-Depth Information
<h:inputText id="line2"
value="#{cc.attrs.namedBean.line2}"/>
<h:outputLabel for="city" value="City"/>
<h:inputText id="city" value="#{cc.attrs.namedBean.
city}"/>
<h:outputLabel for="state" value="state"/>
<h:inputText id="state" value="#{cc.attrs.namedBean.
state}"
size="2" maxlength="2"/>
<h:outputLabel for="zip" value="Zip"/>
<h:inputText id="zip" value="#{cc.attrs.namedBean.zip}"
size="5" maxlength="5"/>
</h:panelGrid>
</cc:implementation>
</html>
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"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ezcomp="http://xmlns.jcp.org/jsf/composite/ezcomp">
<h:head>
<title>Address Entry</title>
</h:head>
<h:body>
<h:form>
 
Search WWH ::




Custom Search