Java Reference
In-Depth Information
<!-- IMPLEMENTATION -->
<cc:implementation>
</cc:implementation>
</html>
Every JSF 2 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 all 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 we can use to enter addresses.
That way, if we have to enter several addresses in an application, we can encapsulate
the logic and/or display part in our component. If later we need to change an
address entry (for example, to support international addresses), we only need
to change our component and all address entry forms in our application will be
updated automatically.
After filling 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://xmlns.jcp.org/jsf/composite"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<!-- INTERFACE -->
<cc:interface>
<cc:attribute name="addrType"/>
<cc:attribute name="namedBean" 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.namedBean.line1}"/>
<h:outputLabel for="line2" value="Line 2"/>
 
Search WWH ::




Custom Search