开发者

JSF 2 composite component, passing attributes to backing bean

开发者 https://www.devze.com 2023-02-20 02:29 出处:网络
I\'m stuck on simple JSF2 question: XHTML: <xvf:simpleOut identifier=\"12345\"/> Composite component is supposed to pass \"12345\" to backing bean and do some output:

I'm stuck on simple JSF2 question:

XHTML:

<xvf:simpleOut identifier="12345"/>

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>

How do I pass identifier value, '12345' in my case, to bean's getTes开发者_如何学GotOutput(String arg) method?


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

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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号