Passing arguments in ajax event JSF action listener

514 views Asked by At

I want to trigger an action everytime I click on an ace:checkBoxButton.

This is my code:

<h:panelGrid columns="2">
     <ui:repeat value="#{controller.targetValues}" var="target" varStatus="metadata">
         <ace:checkboxButton value="#{controller.isTargetChecked(target)}"/>
     </ui:repeat>
</h:panelGrid>

After that, I want to pass my var variable to the listener method.

UPDATE: my problem is that the method in the value attribute is triggered every time the checkbox button is rendered or refreshed. So I need a method that is called only when I click on the checkbox button.

Can you help me please ?

1

There are 1 answers

1
fuggerjaki61 On

My solution is to add an ajax event to the checkbox like this:

<ace:checkboxButton id="checkBox" value="#{controller.isTargetChecked(target)}">
    <p:ajax event="change" listener="#{controller.method}" uptade="@this" />
</ace:checkboxButton>

so the ajax is triggered when something is changed (there are other events but there is no complete list :-( ). method is called when something is changed and uptade is not necessarily but if you edit the checkbox it will be uptaded.