Documentation
Project Documentation
Foundation

Summary

Tag name: <s:globalId>
UIComponent class: org.apache.myfaces.custom.globalId.GlobalId
Tag class: org.apache.myfaces.custom.globalId.GlobalIdTag
Component type: org.apache.myfaces.custom.globalId
Component family: org.apache.myfaces.custom.globalId

A simple container-component that causes its child components to render a clientId value without any prefix.

Important: this component works only when run in a JSF-1.2 (or later) environment. When run in a JSF-1.1 environment it will not cause an error, but will instead act like a NamingContainer itself, ie will add its own id to the child component's clientId.

Every JSF component has a "clientId" property; when the component is rendered, many components output this as part of the rendered representation. In particular, when rendering HTML, many components write an "id" attribute on their html element which contains the clientId. The clientId is defined as being the clientId value of the nearest NamingContainer ancestor plus ":" plus the component's id.

The prefixing of the parent container's clientId is important for safely building views from multiple files (eg using Facelets templating or JSP includes). However in some cases it is necessary or useful to render a clientId which is just the raw id of the component without any naming-container prefix; this component can be used to do that simply by adding an instance of this type as an ancestor of the problem components. This works for all JSF components, not just Tomahawk ones.

Use of this component should be a "last resort"; having clientIds which contain the id of the ancestor NamingContainer is important and useful behaviour. It allows a view to be built from multiple different files (using facelets templating or jsp includes); without this feature, component ids would need to be very carefully managed to ensure the same id was not used in two places. In addition, it would not be possible to include the same page fragment twice.

Ids are sometimes used by Cascading Style Sheets to address individual components, and JSF compound ids are not usable by CSS. However wherever possible use a style class to select the component rather than using this component to assign a "global" id.

Ids are sometimes used by javascript "onclick" handlers to locate HTML elements associated with the clicked item (document.getById). Here, the onclick handler method can be passed the id of the clicked object, and some simple string manipulation can then compute the correct clientId for the target component, rather than using this component to assign a "global" id to the component to be accessed.

This component is similar to the "forceId" attribute available on many Tomahawk components. Unlike the forceId attribute this (a) can be used with all components, not just Tomahawk ones, and (b) applies to all its child components.

Note that since JSF1.2 forms have the property prefixId which can be set to false to make a UIForm act as if it is not a NamingContainer. This is a good idea; the form component should probably never have been a NamingContainer, and disabling this has no significant negative effects.

Attributes

Name Type Supports EL? Description
binding String Only EL Identifies a backing bean property (of type UIComponent or appropriate subclass) to bind to this component instance. This value must be an EL expression.
id String Yes An identifier for this particular component instance within a component view.

The id must be unique within the scope of the tag's enclosing NamingContainer (eg h:form or f:subview). The id is not necessarily unique across all components in the current view

This value must be a static value, ie not change over the lifetime of a component. It cannot be defined via an EL expression; only a string is permitted.

rendered boolean Yes A boolean value that indicates whether this component should be rendered. Default value: true.