HTML and CSS Reference
In-Depth Information
* Gets the client id of the {@link #getForComponent()}
* @return Client id of the {@link #getForComponent()}
* @throws IOException If the component specified in the {@code for}
* attribute could not be found
public String getForClientId() throws IOException {
UIComponent element = getForComponent();
return element.getClientId(getFacesContext());
* Utility method for retrieving the attributes of a component. This method
* first checks if the attribute is an EL Expression followed by checking if
* it is a simple value.
* @param name Name of the attribute to retrieve
* @return The value of the attribute. If the contents of the attribute is
* an EL Expression, the expression will be executed and returned. If the
* contents of the attribute is a simple value, it will be returned as is.
* If the attribute cannot be found {@code null} is returned.
private Object getAttribute(String name) {
ValueExpression ve = getValueExpression(name);
if (ve != null) {
// Attribute is a value expression
return ve.getValue(getFacesContext().getELContext());
} else if (getAttributes().containsKey(name)) {
// Attribute is a fixed value
return getAttributes().get(name);
} else {
// Attribute doesn't exist
return null;
The for attribute supports only media components. For the component to be production ready you should
implement support for other components such as file upload, form completion, and ajax requests.
Usage of the component is straightforward. It can be used as an indeterminate progress bar by providing no
attributes to the component. It can be used as a manually updated determinate bar by providing the value and max
attributes. Finally, it can also be used by pointing the for attribute to a media component. Figure 8-2 is a screenshot of
using the component as shown in Listing 8-17.
Search WWH ::

Custom Search