3

我需要调用复合组件的支持组件(@facescomponent)的方法。我在文章中看到其他人这样做,但没有一个对我有用。

这就是我调用的方式:

<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>

这是支持组件。

@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;
}
}

myAction应该调用方法吗?我做错了什么?

4

1 回答 1

0

您对属性进行调用,因为方法需要使用:action="#{cc.myAction()}"

于 2014-07-02T08:26:11.933 回答