JSF中出现错误的复合组件

JSF中出现错误的复合组件,jsf,composite-component,Jsf,Composite Component,我有下面的复合组件: <composite:interface> <composite:attribute name="acaoDestino" required="true" shortDescription="Método que será executado quando o usuário clicar no botão 'Sim'." /> </composite:interface> <composite:implementa

我有下面的复合组件:

<composite:interface>
<composite:attribute name="acaoDestino" required="true"
        shortDescription="Método que será executado quando o usuário clicar no botão 'Sim'." />
</composite:interface>
<composite:implementation>
<h:commandButton actionListener="#{cc.attrs.acaoDestino}"
                        class="btn btn-primary" value="Sim">
                        <f:ajax render="@all" execute="@all" />
                    </h:commandButton>
</composite:implementation>
重要提示:我不希望这个actionListener调用两次。另一个重要的注意事项是,我正在绑定一个datatable,我不知道这是否会导致这个问题

编辑1

My Acadestino是ManagedBean中的一种方法,请参见:

public void removeSelected() {
...
}
在commandButton中直接使用如下内容:

<h:commandButton actionListener="#{myManagedBean.removeSelected()}"
                        class="btn btn-primary" value="Sim">
                        <f:ajax render="@all" execute="@all" />
                    </h:commandButton>
<composite:interface>
        <composite:attribute name="acaoDestino" required="true" method-signature="void actionListener()"
                shortDescription="Método que será executado quando o usuário clicar no botão 'Sim'." />
</composite:interface>
<composite:implementation>
        <h:commandButton actionListener="#{cc.attrs.acaoDestino}" class="btn btn-primary" value="Sim">
               <f:ajax render="@all" execute="@all" />
        </h:commandButton>
</composite:implementation>
我在另一个复合组件中使用复合组件,看:

<jw:confirmButton
            acaoDestino="#{cc.attrs.managedBeanName.removeSelected()}"
            value="Remover Selecionados" />

你能告诉我阿卡德斯蒂诺到底是什么吗?支持bean中的方法变量?因为如果它是您必须在buttonCommand action=“”或listener=“”

中使用的方法或变量,请尝试使用:

<h:commandButton listener="#{myManagedBean.removeSelected()}"
                    class="btn btn-primary" value="Sim">
                    <f:ajax render="@all" execute="@all" />
                </h:commandButton>

或:


首先,您必须指定一个方法签名,以便JSF知道它是一个方法表达式而不是一个值表达式,您的复合组件应该如下所示:

<h:commandButton actionListener="#{myManagedBean.removeSelected()}"
                        class="btn btn-primary" value="Sim">
                        <f:ajax render="@all" execute="@all" />
                    </h:commandButton>
<composite:interface>
        <composite:attribute name="acaoDestino" required="true" method-signature="void actionListener()"
                shortDescription="Método que será executado quando o usuário clicar no botão 'Sim'." />
</composite:interface>
<composite:implementation>
        <h:commandButton actionListener="#{cc.attrs.acaoDestino}" class="btn btn-primary" value="Sim">
               <f:ajax render="@all" execute="@all" />
        </h:commandButton>
</composite:implementation>
在这种情况下,方法签名属性变为:

method-signature="void actionListener(ActionEvent e)

NB:命令组件在激活时提交请求,因此在刷新整个页面时无需使用

很好,请尝试使用action=“emoveSelected”或listener=“#{removeSelected”,但我需要使用'acaoDestino'而不是'removeSelected()因为actionListener可以更改。你说Acadestino是bean中的一个方法或字段,我想说它是bean中的一个属性?Acadestino是一个“属性”在composite:implementation.ok中使用的复合组件中,如果没有listener,这意味着jsf的版本低于2.2,在这种情况下,您必须使用Just action。是否可以显示bean中具有名为:acaoDestino和make sur的属性的部分(如果有)、getter和setters?listener属性在commandButton JSF中不存在,而action给了我同样的问题。如果不起作用,我用新信息编辑了我的文章。我使用的是JSF 2。2@user2776409请提供如何在xhtml页面中使用复合组件?您必须这样使用它:请删除value属性,因为您没有在xhtml页面中声明它CC接口,我正在使用您相同的代码和它的工作!让我们。
<composite:interface>
        <composite:attribute name="acaoDestino" required="true" method-signature="void actionListener()"
                shortDescription="Método que será executado quando o usuário clicar no botão 'Sim'." />
</composite:interface>
<composite:implementation>
        <h:commandButton actionListener="#{cc.attrs.acaoDestino}" class="btn btn-primary" value="Sim">
               <f:ajax render="@all" execute="@all" />
        </h:commandButton>
</composite:implementation>
public void removeSelected(ActionEvent e) {
...
}
method-signature="void actionListener(ActionEvent e)