JSF 2复合组件,将属性传递到支持Bean [英] JSF 2 composite component, passing attributes to backing bean

查看:72
本文介绍了JSF 2复合组件,将属性传递到支持Bean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我陷入了一个简单的JSF2问题:

I'm stuck on simple JSF2 question:

XHTML:

<xvf:simpleOut identifier="12345"/>

复合组件应该将 12345传递给支持bean并执行一些输出:

Composite component is supposed to pass "12345" to backing bean and do some output:

<composite:interface>
    <composite:attribute name="identifier" required="true" type="java.lang.String"/>
</composite:interface>

<composite:implementation>
    <!--@elvariable id="arg" type="java.lang.String"-->
    <ui:param name="arg" value="#{cc.attrs.identifier}"/>
    <h:outputText value="#{myBean.getTestOutput('???????')}"/>
</composite:implementation>

如何传递标识符的值,在我的情况下为12345,到bean的 getTestOutput(String arg)方法?

How do I pass identifier value, '12345' in my case, to bean's getTestOutput(String arg) method?

推荐答案

您根本不需要< ui:param> 标记。这应该起作用:

You don't need the <ui:param> tag at all. This should work:

<h:outputText value="#{myBean.getTestOutput(cc.attrs.identifier)}"/>

但通过 myBean 也可以通过该接口而不是直接引用它,因为它将使复合组件可重用。

But it might a a good idea to pass myBean through the interface as well rather than refering to it directly, since it would make the composite component reusable.

这篇关于JSF 2复合组件,将属性传递到支持Bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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