Ajax调用p:selectManyCheckbox

DuS*_*ant 0 java ajax primefaces

嗨大家有没有办法在ap:selectManyCheckbox中触发ajax调用一旦我检查其中一个?这样的事情:

<p:selectManyCheckbox  label="Elements" value="#{crearVacacionMB.elementSelected}" layout="grid" columns="1">
    <f:selectItems  value="#{MB.elements}" />
    <p:ajax event="check" listener="#{MB.function}"/>
</p:selectManyCheckbox>
Run Code Online (Sandbox Code Playgroud)

我的MB:

public void function(AjaxBehaviorEvent event){
    System.out.println("I was fired");

}
Run Code Online (Sandbox Code Playgroud)

per*_*ssf 6

你发布的代码产生了一个JSF错误,至少在Mojarra 2.2中,我很惊讶你没有提到它:

<p:ajax> Event:check is not supported.
Run Code Online (Sandbox Code Playgroud)

从以下event属性中删除属性<p:ajax>:ajax行为将默认为默认事件valueChange:

<p:ajax listener="#{MB.function}"/>
Run Code Online (Sandbox Code Playgroud)

链接: