JSF 2 composite component, passing attributes to backing bean
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.
精彩评论