Add passThroughAttribute to SelectItem

天大地大妈咪最大 提交于 2019-12-11 07:46:20

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/18697709/add-passthroughattribute-to-selectitem

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!