2
votes

I have 3 files:

main.xhtml

<ui:include src="included.xhtml">
    <ui:param name="bean" value="#{invoices}" />
    <ui:param name="method" value="initExchange" />
</ui:include>

included.xhtml

<s:compositeComponent bean="#{bean}" beanMethod="#{method}"
                    buttonActionListener="#{bean[method]()}" />

compositeComponent.xhtml

<cc:interface>
    <cc:attribute name="bean" />
    <cc:attribute name="beanMethod" />
    <cc:attribute name="buttonActionListener" method-signature="void f()" />
</cc:interface>
<cc:implementation>
    <h:outputText value="#{cc.attrs.bean}" />
    <h:outputText value="#{cc.attrs.beanMethod}" />
    <p:commandButton actionListener="#{cc.attrs.buttonActionListener}" />

h:outputTexts are OK. But clicking on button gives exception:

Target Unreachable, identifier 'bean' resolved to null

How to pass the method to button's actionListener?

1

1 Answers

1
votes

It works when actionListener in composite component is written as bean[method] like in included.xhtml:

<p:commandButton actionListener="#{cc.attrs.bean[cc.attrs.beanMethod]}" />

So generally passing method attributes through multiple stages should always be done by separate bean and method rather then one attribute with 'method-signature'.