自定义组件用户对象值
我想在 JSF2 中创建一个自定义组件(改进outputLink),是否可以在属性中使用自定义用户对象?
<my:cLink param="#{bean.userObject}" />
private MyUserClass userObject
你知道在 JSF2.0 中创建自定义组件的教程吗,我找到了 http://www. exadel.com/web/portal/jsftutorial-customcomponents 但它适用于 JSF1.2。我发现一些注释似乎可以简化业务。
感谢您。
I want to create a custom component in JSF2 (kind of improve outputLink), is it possible to use custom user object in the attribute?
<my:cLink param="#{bean.userObject}" />
private MyUserClass userObject
Do you know tutorial for creating custom component in JSF2.0, I found http://www.exadel.com/web/portal/jsftutorial-customcomponents but it's for JSF1.2. I see that some annotation appear to simplify the business.
Thanks you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您已经使用了 JSF 2.0,您确定要创建一个 自定义组件而不是复合组件?无论哪种方式,您当然必须能够使用非标准类型作为属性值。在扩展
UIComponent
(或者更好,UIComponentBase
),可以使用继承的getAttributes()
方法获取:自定义组件只有一个注解,
@FacesComponent
。它只是faces-config.xml
中
条目的替换。对于剩余部分,JSF 1.2 和 2.0 之间没有太大差异,除了对部分状态保存的新支持之外。您可以安全地遵循 JSF 1.2 针对自定义组件的教程。Since you're already on JSF 2.0, are you sure that you want to create a custom component rather than a composite component? Either way, certainly you must be able to use non-standard types as attribute value. In a custom component which extends
UIComponent
(or better,UIComponentBase
), you can use the inheritedgetAttributes()
method to obtain it:There's only one annotation for custom components, the
@FacesComponent
. It is just a replacement of the<component>
entry infaces-config.xml
. For the remnant there are no big differences between JSF 1.2 and 2.0, expect of the new support for partial state saving. You could safely follow the JSF 1.2 targeted tutorials for custom components.