2

I have simple composite component button.xhtml:

<composite:interface>
    <composite:attribute name="action" method-signature="void listener(java.lang.String)"/>
</composite:interface>

<composite:implementation>
    <h:form>
        <h:commandButton value="button" action="#{cc.attrs.action}"/>
    </h:form>
</composite:implementation>

It is used on details.xhtml page:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:comp="http://java.sun.com/jsf/composite/comp">
    <comp:button action="#{actionBeanParam.doAction('someParam')}"/>
</ui:composition>

details.xhtml page is included into another page. Pay attention to actionBeanParam. It is passed as a parameter to details.xhtml. The page display two buttons (for testing purposes) - the first button is just to check that the composite component works. The second button is what I want to achieve:

<h:body>
    <comp:button action="#{actionBean.doAction('simpleButton')}"/>
    <ui:include src="/WEB-INF/blocks/details.xhtml">
        <ui:param name="actionBeanParam" value="#{actionBean}"/>
    </ui:include>
</h:body>

And finally backing bean:

@Named
@SessionScoped
public class ActionBean implements Serializable {
    public void doAction(String param) {
        System.out.println("Param: " + param);
        // some action
    }
}

When I press top button it works fine. In console I see:

Param: simpleButton

When I press bottom button (my scenario) it throws exception:

javax.el.PropertyNotFoundException: JBWEB006016: Target Unreachable, identifier ''actionBeanParam'' resolved to null: javax.faces.el.EvaluationException: javax.el.PropertyNotFoundException: JBWEB006016: Target Unreachable, identifier ''actionBeanParam'' resolved to null

I found the similar issue here: Managed Bean as Facelet parameter lets composite component prevent resolving

But I can't use the workaround from this issue because my action has a parameter.

I have a workaround to reSet the parameter via c:set in details.xhtml:

<c:set var="actionBeanParam" scope="view" value="#{actionBeanParam}" />

but it works incorrectly when details.xhtml is included more than once.

What I am using: JBoss EAP 6.2.1, Mojarra 2.1.19-jbossorg-1

Any suggestions?

Community
  • 1
  • 1
A.Panzer
  • 391
  • 3
  • 15
  • I just got bit by this as well. Really hoping there is a solution because I'm already using this composite component everywhere in my app... – wsaxton Oct 19 '15 at 14:25

0 Answers0