将passThroughAttribute添加到SelectItem [英] Add passThroughAttribute to SelectItem

查看:138
本文介绍了将passThroughAttribute添加到SelectItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想将passThroughAttributes添加到选择 -element的某些选项,我可以使用 f:passThroughAttribute 作为<组件的子组件a href =http://docs.oracle.com/javaee/7/javaserverfaces/2.2/vdldocs/facelets/f/selectItem.html\"rel =nofollow> f:selectItem 。

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.

但通常我使用 List 6 / api / javax / faces / model / SelectItem.htmlrel =nofollow> SelectItems 生成选项。与 UiComponent相反 SelectItem 没有方法 getPassThroughAttributes

But normally I'm using a List of SelectItems to generate the options. In contrast to UiComponent SelectItem does not have a method getPassThroughAttributes.

有人知道原因吗?

推荐答案

这是因为它没有渲染器相关联。如果< f:xxx> 组件(标签处理程序和模型),则它是最接近的父< h:xxx> 组件( UIComponent 实例)或者,如果有的话,最接近的嵌套< h:xxx> 组件有一个 Renderer 相关联。 Renderer 即负责生成所有HTML输出,包括passthrough属性。请注意,在这种情况下,passthrough属性在< h:xxx> 组件本身上设置。

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.

如果您打算控制/操纵生成的< option> 元素的属性,那么您无法绕过创建自定义渲染器,如有必要,基于标准的 Renderer 实现。

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.

这篇关于将passThroughAttribute添加到SelectItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆