cc

Tag Library Information 
InfoValue
ID (tag prefix)cc
URIjakarta.faces.composite
Tag Summary 
TagDescription
actionSource

Declares that the composite component whose contract is declared by the <cc: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. Any attached objects suitable for implementations of ActionSource2 may be attached to the composite component. Consider this excerpt from the using page:

  1. <ez:loginPanel id="loginPanel" model="#{bean}">
  2.   <f:valueChangeListener for="username"
  3.                          binding="#{bean.useridValueChangeListener}" />
  4.   <f:actionListener for="loginEvent"
  5.                     binding="#{bean.loginEventListener}" />
  6.   <f:actionListener for="cancelEvent"
  7.                     binding="#{bean.cancelEventListener}" />
  8.   <f:actionListener for="allEvents"
  9.                     binding="#{bean.allEventsListener}" />
  10. </ez:loginPanel>

The <f:actionListener> elements on lines 4, 7, and 10 refer to the attached objects declared on lines 2, 3 and 4 below.

  1. <cc:interface name="loginPanel">
  2.   <cc:actionSource name="loginEvent" />
  3.   <cc:actionSource name="cancelEvent" />
  4.   <cc:actionSource name="allEvents" targets="loginEvent cancelEvent" />
  5. </cc:interface>

Most of the concepts from example content from <cc:valueHolder> also applies in the case of <cc:actionSource>.

Please see <cc:interface> for a usage example.

attribute

Declares an attribute that may be given to an instance of the composite component tag for this composite component. There may be zero or many of these inside of the <cc:interface> section. This element may be nested within other <cc:attribute> elements to convey a usage contract that includes nested properties.

Please see summary page for a usage example.

The top level component in which this element is ultimately nested must be a NamingContainer. There are certain component properties that must not be exposed using this element. The motivation for this restriction is that the mapping of markup attributes to component properties/attributes does not allow for these attributes to be set. The following properties must not be exposed using this element.

  • binding
  • id
  • inView
  • parent
  • rendered
  • rendererType
  • transient
clientBehavior

Declares that the composite component whose contract is declared by the <cc:interface> in which this element is nested exposes an implementation of ClientBehaviorHolder suitable for use as the target of attached objects in the using page. Any attached objects suitable for implementations of ClientBehaviorHolder may be attached to the composite component.

editableValueHolder

Declares that the composite component whose contract is declared by the <cc: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. Any attached objects suitable for implementations of EditableValueHolder may be attached to the composite component.The example from <cc:valueHolder> still applies.

Please see <cc:interface> for a usage example.

extension

Used within a <cc:interface> section, within any sub-element of that section, to include XML content not defined by this specification. This element can be used to incorporate JSR-276 metadata into a composite component.

facet

Declares that this composite component supports a facet with the name given by the value of the "name" attribute.

Please see <cc:interface> for a usage example.

implementation

Defines the implementation of the composite component. There must be zero or one of these in a composite component markup file. If a <cc:interface> element appears, there must be a corresponding <composite-implementation> element. If no <cc:interface> element appears, the <composite-implementation> element is optional.

insertChildren

This element is used in the <cc:implementation> section. Any child components or template text within the composite component tag in the using page will be re-parented into the composite component at the point indicated by this tag's placement within the <cc:implementation> section. The normal use-case for this element is to have only one occurrence within the <cc:implementation> section. Inserting multiple occurrences may cause duplicate id errors. The results are undefined if there are multiple occurrences of this element in the <cc:implementation> section.

insertFacet

The presence of this tag in a <cc:implementation> section must cause the named facet to be taken from the facet map of the top level component and inserted as a facet child of the component in which this element is nested. The results are undefined if there are facets in the composite component tag in the using page, but there is no correspondingly named occurrence of this element in the <cc:implementation> section.

interface

This element declares the usage contract for a composite component. Optionally, and at the component author's discretion, this contract exposes the features of one or more inner components to the page author. The page author can work with the composite component as a single component whose feature set is the union of the features declared in the usage contract.

For example, consider a composite component that implements the functionality of a "login panel". Such a component would likely have two text fields and one button. The user of such a component might like to do one or more of the following.

  • Be able to listen for the ActionEvent on the button.

    In this case, a <cc:actionSource> element is included in the usage contract that refers to the inner button in the <cc:implementation> section.

  • Provide an "action" to invoke when the button is pressed.

    In this case, a <cc:attribute> element is included in the usage contract that refers to the inner button in the <cc:implementation> section and declares the proper method signature for an "action".

  • Provide parameters to the composite component for labels and other rendering specific aspects of the composite component.

    In this case, one or more <cc:attribute> elements are included in the usage contract and those parameters are referred to in the <cc:implementation> section using EL expressions like #{cc.attrs.usernameLabel}, assuming usernameLabel is the name of one of the <cc:attribute> elements in the usage contract.

  • Add ValueChangeListeners, Converters, or Validators to either or both text fields.

    In this case, a <cc:editableValueHolder> element is included in the usage contract that refers to the inner text field in the <cc:implementation> section. In the case of wanting to enable only adding a Converter (and not a ValueChangeListener or Validator, a <cc:valueHolder> element would be used.

  • Add facet children to the login panel.

    In this case, a <cc:facet> element is included in the usage contract that refers to the inner <cc:renderFacet> element in the <cc:implementation> section.

For each of the behaviorial interfaces in section 3.2 "Component Behavioral Interfaces" of the Jakarta Faces Specification Document, there is a tag in the cc: library to nest inside of the <cc:interface> section.

If the <cc:interface> section is not present in a VDL view, the contract will be inferred as described in the specification. There must be zero or one of these elements in a composite component VDL file. If a <cc:interface> element does appear, there must be an accompanying <cc:implementation> element in the same VDL file.

Nesting of composite components

The implementation must support nesting of composite components. Specifically, it must be possible for the <cc:implementation> section of a composite component to act as the using page for another composite component. When a composite component exposes a behavioral interface to the using page, such as a <cc:actionSource>, <cc:editableValueHolder>, <cc:valueHolder> or other behavioral interface, it must be possible to “propogate” the exposure of such an interface in the case of a nested composite component. The composite component author must ensure that the value of the name attributes exactly match at all levels of the nesting to enable this exposure to work. The implementation is not required to support “re-mapping” of names in a nested composite component.

For example, consider this nested composite component.

Using page

  1. <ez:actionSourceOuter>
  2.   <f:actionListener for="button1" />
  3. </ez:actionSourceOuter>

actionSourceOuter.xhtml: Outer composite component

  1. <cc:interface>
  2.   <cc:actionSource name="button1" />
  3. </cc:interface>
  4. <cc:implementation>
  5.   <ez:actionSourceInner />
  6. </cc:implementation>

actionSourceInner.xhtml: the composite component used within a composite component.

  1. <cc:interface>
  2.   <cc:actionSource name="button1" />
  3. </cc:interface>
  4. <cc:implementation>
  5.   <h:commandButton id="button1" value="the real button" />
  6. </cc:implementation>

The id of the <h:commandButton> on line 6 of actionSourceInner.xhtml must match the name on line 2 of that file (this is a standard requirement for all composite components, nested or not). That id must also match the name on line 2 of actionSourceOuter.xhtml, and the for on line 2 of the using page.

The implementation must support any level of nesting as long as the for, name, and id values match up. Furthermore, the targets attribute is also valid for use in this nested fashion.

Naming containers within composite components

Composite components are themselves naming containers so that any possible id conflicts between inner components and components in the using page are avoided. However, special care must be taken when using naming containers in the <cc:implementation> section. In such cases the value of the “name” attribute, or the values of the “targets” attribute must be used with a clientId relative to the top level component to expose any attached object targets to the using page. For example:

Using page

  1. <ez:loginButton>
  2.   <f:actionListener for="button" binding="#{foo.actionListener}" />
  3. </ez:loginButton>

loginButton.xhtml

  1. <cc:interface>
  2.   <cc:actionSource name="button" targets="form:button" />
  3. </cc:interface>
  4. <cc:implementation>
  5.   <h:form id="form">
  6.     <h:commandButton id="button" value="Submit" />
  7.   </h:form>
  8. </cc:implementation>

Because the button on line 8 resides within a form, it must be referred to using a client id, relative to the top level component, in the "targets" attribute on line 2. Using a relative clientId is required due to the semantics of UIComponent.findComponent().

renderFacet

This element is used in the <cc:implementation> section. The facet with the name equal to the value of the name attribute, given by the page author in the using page, will be rendered at this point in the composite component VDL view.

The implementation of this tag handler must insert a component with component-type jakarta.faces.Output and renderer-type jakarta.faces.CompositeFacet as a child at this point in the component tree.

The implementation of this tag handler must store an attribute into the created component's attribute map under the key given by the value of the symbolic constant UIComponent.FACETS_KEY. The value for this key must be the evaluated value of the "name" attribute.

valueHolder

Declares that the composite component whose contract is declared by the <cc: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. Any attached objects suitable for implementations of ValueHolder may be attached to the composite component. Consider this excerpt from the using page:

  1. <ez:foo>
  2.   <f:converter for="userid" binding="#{bean.converter}" />
  3. </ez:foo>

Line 2 refers to the <cc:valueHolder> declaration on line 2 of foo.xhtml:

  1. <cc:interface>
  2.   <cc:valueHolder name="userid" />
  3. </cc:interface>
  4. <cc:implementation>
  5.   <h:inputText id="userid" />
  6. </cc:implementation>

It is possible to declare that a single <cc:valueHolder> element should cause multiple components within the <cc:implementation> section to be the targets of an attached object in the using page. Assuming the same using page excerpt as above, the revised VDL view is:

  1. <cc:interface>
  2.   <cc:valueHolder name="inputs" targets="userid,password" />
  3. </cc:interface>
  4. <cc:implementation>
  5.   <h:inputText id="userid" />
  6.   <h:inputText id="password" />
  7. </cc:implementation>

In this case, the "targets" attribute on the <cc:valueHolder> element, on line 2 above, replaces the "name" attribute in the previous example. "targets" is a list of ids of client ids (relative to the top level component) within the <cc:implementation> section. In this case, "targets" refers to the <h:inputText> components on lines 6 and 7 above.

Please see <cc:interface> for a usage example.