andbi
andbi

Reputation: 4454

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 getTestOutput(String arg) method?

Upvotes: 1

Views: 5176

Answers (1)

Michael Borgwardt
Michael Borgwardt

Reputation: 346260

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.

Upvotes: 4

Related Questions