Java Reference
In-Depth Information
Pass-through attributes
During the generation of web pages that will be sent to the browser, the attributes for
each JSF component are interpreted and validated by the
UIComponent
or Render-
er. Unlike adding HTML5 attributes into all JSF components so that they can be val-
idated by the
UIComponent
or Renderer, pass-through attributes give developers
the ability to list a set of attributes that will be passed straight through to the browser
without being interpreted by the
UIComponent
or Renderer. This can be done with
three different approaches:
• By introducing the namespace
xmlns:pta="http://xmlns.jcp.org/
jsf/passthrough"
; this will be used to prefix all of the component attrib-
utes that must be copied without interpretation into the web page intended for
the browser (see
Pass through attributes 1
in the code that follows)
• By nesting the
<f:passThroughAttribute>
tag within a
UIComponent
tag for a single attribute (see
Pass through attributes 2
in the follow-
ing code)
• By nesting the
<f:passThroughAttributes>
tag within a
UIComponent
tag for an EL value that is evaluated to
Map<String, Object>
(see
Pass
through attributes 3
in the code that follows)
<!-- namespace -->
<html ...
xmlns:pta="http://xmlns.jcp.org/jsf/
passthrough">
<h:form>
<!-- Pass through attributes 1 -->
<h:inputText pta:type="image"
pta:src="img_submit.gif"
value="image1"
pta:width="58" pta:height="58" />
<!-- Pass through attributes 2 -->
<h:inputText value="image2" >
<f:passThroughAttribute
name="type" value="image" />
<f:passThroughAttribute