'h:selectBooleanCheckbox not firing a4j:ajax listener inside rich:datatable on first click

When checking the h:selectBooleanCheckBox the first time, the listener is not fired. Checking it again, does fire the listener. I've also tried doing a valueChangeListener="selectRoleCheckboxChangeListener" attribute for the h:selectBooleanCheckBox with the same result. It will work on the 2nd and subsequent clicks. I'd like to have this fire on the first click. Ideas? Thanks

<rich:dataTable id="roleTable" 
    value="#{roleBean.displayedRoles}" 
    var="roleItem"  
>
    <rich:column 
        id="selectRoleCheckboxColumn" 
    >
        <f:facet name="header">Select Role</f:facet>
        <h:selectBooleanCheckbox
            id="selectRoleCheckbox" 
            value="#{roleItem.selectRole}" 
            binding="#{roleBean.selectRoleCheckbox}"
        >
            <a4j:ajax 
                event="click" 
                listener="#{authorizationBean.selectRoleCheckboxListener}"
            /> 
        </h:selectBooleanCheckbox>
    </rich:column>
</rich:dataTable>


Solution 1:[1]

I had the same problem. I found the solution for the above problem.

The problem will be either your component doesn't have id's or object or values set are not getting reflected. Another problem would be inner form.

Solution would be... Set id's for all your component and if the values are not getting reflected on ajax request, render the components for which values are set. Do not have form inside a form.

Hope it should work...

This is a very old post. Still might be useful for someone.

Solution 2:[2]

Try it this way

<h:selectBooleanCheckbox id="selectRoleCheckbox" value="#{roleItem.selectRole}"         
  <a4j:support event="onchange" action="#{authorizationBean.selectRoleCheckboxListener}"/>
</h:selectBooleanCheckbox>

hope it works..

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vandana Acharya
Solution 2 Mango