3

I need to invoke a method of backing component(@facescomponent) of composite component. I see others do this in articles but none of them has ever worked for me.

this how I invoke:

<ui:component xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:cc="http://java.sun.com/jsf/composite">

<cc:interface componentType="formField"/>

<cc:implementation>
    <h:commandButton value="doIt" action="#{cc.myAction}" ></h:commandButton>
</cc:implementation>
</ui:component>

and this is the backing component.

@FacesComponent("formField")
public class Field extends UICommand implements NamingContainer {

public Field() {
}

@Override
public String getFamily() {
    return UINamingContainer.COMPONENT_FAMILY;
}
public String myAction() {

    System.out.println("in action");//not printed
    return null;
}
}

Shouldn't myAction method be invoked? What did I do wrong?

John Yeary
  • 1,112
  • 22
  • 45
lazyCoding
  • 481
  • 2
  • 5
  • 13
  • I used your code as noted above with a minor correction, and it printed out the `in action` value in my server logs. I used JSF 2.2 on Apache Tomcat 8.0.9. I don't see an error. Do you have any further information? – John Yeary Oct 31 '14 at 15:09
  • well, that was mounts ago.I don’t even remember what happened to that code. thanks for reply anyway. – lazyCoding Nov 07 '14 at 12:12
  • check this http://stackoverflow.com/questions/9913791/invoke-actionlistener-of-backing-component-in-composite-component – Abdulkader Dec 22 '14 at 10:15

1 Answers1

0

you do an invoke for property, for method need to use: action="#{cc.myAction()}"