Java Reference
In-Depth Information
<br/>
</p>
</h:form>
</f:view>
</ui:define>
</ui:composition>
</h:body>
</html>
Along with this enhancement, the javax.faces.render.ResponseStateManager.isStateless(FacesContext
context, String viewId) method has been added to determine whether the previous state that was posted
contains any state. All views that are marked as stateless cause a value of “ stateless ” to be assigned to the view state
parameter “ javax.faces.ViewState ”. Therefore, a call to the new isStateless method checks this parameter.
HTML5 and JSF
One of the most prominent new capabilities of JSF 2.2 is increased support for HTML5. There have been some
significant improvements to JSF that help facilitate the use of HTML5 attributes with standard JSF components, as well
as including HTML5 tags within JSF views. This section covers a couple of these new features, including passthrough
attributes and HTML5-friendly markup. After reading these sections, you will be able to incorporate modern HTML5
abilities into your JSF views with ease.
Passthrough Attributes
One major hurdle for using HTML5 along with standard JSF components is that there are attributes required by
HTML5 tags that are not supported by the JSF components. HTML5 tags include data attributes that have the purpose
of attaching data to HTML elements. The JSF components do not support these data attributes, but with the JSF 2.2
release, a new approach, known as passthrough attributes , helps resolve this issue. JSF passthrough attributes allow
for attributes to be set for JSF components, to be passed through to the client directly, and not be consumed and/or
processed by the component at all.
There are a few different ways to implement passthrough attributes. The first way is to use the new taglib URI
( xmlns:p=" http://xmlns.jcp.org/jsf/passthrough " ), along with the new attribute p:placeholder to set the attribute.
Using this technique, any JSF component can accept a p:placeHolder attribute, and it will be ignored by the component.
The following example demonstrates how to utilize the p:placeHolder attribute of an inputText component:
<h:inputText value="#{ptBean.ptValue1}" p:placeholder="Passthrough Attribute 1">
<f:ajax execute="@this" update="ptValues"/>
</h:inputText>
Another way to make use of passthrough attributes is to utilize a tag handler by embedding the
f:passThroughAttribute tag inside a JSF component. The following example demonstrates the use of the
f:passThroughAttribute tag:
<h:inputText value="#{ptBean.ptValue2}" >
<f:passThroughAttribute name="ptValue2" value="Passthrough Attribute 2" />
<f:ajax execute="@this" update="ptValues"/>
</h:inputText>
 
Search WWH ::




Custom Search