If I want to add passThroughAttributes to some of the options
of a select
-element I can use f: passThroughAttribute as child-component of f:selectItem.
But normally I'm using a List
of SelectItems to generate the options. In contrast to UiComponent
SelectItem
does not have a method getPassThroughAttributes.
Anybody knows a reason why?
It's because it doesn't have a Renderer
associated. In case of <f:xxx>
components (taghandlers and models) it's instead the closest parent <h:xxx>
component (UIComponent
instances) or, if any, the closest nested <h:xxx>
component which does have a Renderer
associated. The Renderer
is namely the one responsible for generating all HTML output, including passthrough attributes. Note that the passthrough attributes have in such case to be set on the <h:xxx>
component itself.
If you intend to control/manipulate the attributes of generated <option>
elements, then you can't go around creating a custom Renderer
, if necessary based on the standard Renderer
implementation.