vendredi 2 octobre 2015

Why JSF checkBox inputs new value to map

I have a checkBox inside dataTable in my JSF page with value, which it gets from map which is in bean.

<h:selectBooleanCheckbox id="rowChecked"
    value="#{messagesListBean.selectedRowIndexesMap[rowIndex]}">
        <a4j:ajax event="click" execute="@this" render="@none"
            limitRender="true"
            listener="#{messagesListBean.rowChecked(rowIndex, rec)}">
        </a4j:ajax>
    </h:selectBooleanCheckbox>
<h:outputLabel for="rowChecked" class="checkbox-style" />

Map is initialized when page loads and it initializes just fine - has 4 values, all of them are false. Map itself looks like this:

public Map<Integer, Boolean> selectedRowIndexesMap = new HashMap<Integer, Boolean>();

The problem is when I press one of the checkBoxes. It should edit value inside the map according to rowNumber. What it does is it add completely new element to the map, it does not edit it.

For example, if before clicking checkbox map looked like this: 0-false; 1-false; 2-false; 3-false;

After clicking the checkbox, it looks like this: 0-true; 0-false; 1-false; 2-false; 3-false;

Why is this happening?




Aucun commentaire:

Enregistrer un commentaire