Wednesday, October 26, 2011

Composite Components -- The Java EE 6 Tutorial -- JSF 2.0

From Java EE 6 Tutorial here.


JavaServer Faces technology offers the concept of composite components with Facelets. A composite component is a special type of template that acts as a component.

Any component is essentially a piece of reusable code that behaves in a particular way. For example, an inputText component accepts user input. A component can also have validators, converters, and listeners attached to it to perform certain defined actions.

A composite component consists of a collection of markup tags and other existing components. This reusable, user-created component has a customized, defined functionality and can have validators, converters, and listeners attached to it like any other component.

With Facelets, any XHTML page that contains markup tags and other components can be converted into a composite component. Using the resources facility, the composite component can be stored in a library that is available to the application from the defined resources location.

Table 5-3 lists the most commonly used composite tags and their functions.



Table 5-3 Composite Component Tags



































TagFunction
composite:interfaceDeclares the usage contract for a composite component. The composite component can be used as a single component whose feature set is the union of the features declared in the usage contract.
composite:implementationDefines the implementation of the composite component. If a composite:interface element appears, there must be a corresponding composite:implementation.
composite:attributeDeclares an attribute that may be given to an instance of the composite component in which this tag is declared.
composite:insertChildrenAny child components or template text within the composite component tag in the using page will be reparented into the composite component at the point indicated by this tag’s placement within the composite:implementation section.
composite:valueHolderDeclares that the composite component whose contract is declared by the composite:interface in which this element is nested exposes an implementation of ValueHolder suitable for use as the target of attached objects in the using page.
composite:editableValueHolderDeclares that the composite component whose contract is declared by the composite:interface in which this element is nested exposes an implementation of EditableValueHolder suitable for use as the target of attached objects in the using page.
composite:actionSourceDeclares that the composite component whose contract is declared by the composite:interface in which this element is nested exposes an implementation of ActionSource2 suitable for use as the target of attached objects in the using page.

For more information and a complete list of Facelets composite tags, see the documentation at http://download.oracle.com/javaee/6/javaserverfaces/2.1/docs/vdldocs/facelets/.

No comments:

Post a Comment