Java Reference
In-Depth Information
Every JSF 2.0 composite component contains two sections, an interface and an
implementation.
The interface section must be enclosed inside a <cc:interface> tag. In the interface,
we define any attributes that our component will have.
The implementation section contains the markup that will be rendered when we use
our composite component.
In our example, we will develop a simple component which we can use to enter the
addresses. That way, if we have to enter several addresses in an application, we can
encapsulate the logic and/or display in our component. If later we need to change
the address entry (to support international addresses, for example), we only need
to change our component and all address entry forms in our application will be
updated automatically.
After "illing in the blanks", our composite component now looks like this:
<?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:cc="http://java.sun.com/jsf/composite"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<!-- INTERFACE -->
<cc:interface>
<cc:attribute name="addrType"/>
<cc:attribute name="managedBean" required="true"/>
</cc:interface>
<!-- IMPLEMENTATION -->
<cc:implementation>
<h:panelGrid columns="2">
<f:facet name="header">
<h:outputText value="#{cc.attrs.addrType} Address"/>
</f:facet>
<h:outputLabel for="line1" value="Line 1"/>
<h:inputText id="line1" value="#{cc.attrs.managedBean.
line1}"/>
<h:outputLabel for="line2" value="Line 2"/>
<h:inputText id="line2" value="#{cc.attrs.managedBean.
line2}"/>
<h:outputLabel for="city" value="City"/>
<h:inputText id="city" value="#{cc.attrs.managedBean.
city}"/>
 
Search WWH ::




Custom Search