mardi 6 novembre 2018

Primefaces Datatable Hashmap Column, first row value not updating if edit

I got a Datatable on Primefaces and one Column is a HashMap data:

private HashMap<Long,Boolean> checkboxChecked = new HashMap<Long,Boolean>();

That HashMap has by default the key(than are ok) and values (false)

It looks like this:

enter image description here

But for some reason, the first value is not changing to true if I check it, or check it all:

enter image description here

When I debug the program it seems as if it has changed (Key 70):

enter image description here

But, ok, just at this moment, just a visual problem or something, the thing is when I check that value to make it false, give's the sense that it change, an when I check it again it still true

Something is happening just to that first value, I can't achieve what could be happening to this.

This is my implementation:

On .xhtml on the Datatable (the idea of that boolean it's to don't show the column, unable all rows on false if a limit of 20 checkboxes is reached)

disabledSelection="#{trackingController.selectedVehicles.size() ge 20 and trackingController.checkboxChecked[vehicle.vehicleId] eq false}"

<p:column visible="true">
    <p:inputText type="text" styleClass="mapCol" value="#{trackingController.checkboxChecked[vehicle.vehicleId]}" converter="javax.faces.Boolean"></p:inputText>
</p:column>

On my Controller

When I fill it:

for(VehicleEntity vehicle: vehicles){
    checkboxChecked.put(vehicle.getVehicleId(),false);
}

When I click one (to true)

checkboxChecked.remove(vehicleEntity.getVehicleId());
checkboxChecked.put(vehicleEntity.getVehicleId(),true);

When I click one (to false)

checkboxChecked.remove(vehicleEntity.getVehicleId());
checkboxChecked.put(vehicleEntity.getVehicleId(),false);

When I click all (to true)

for(VehicleEntity vehicleEntity : selectedVehicles){
    checkboxChecked.put(vehicleEntity.getVehicleId(),true);
}

When I click all (to false)

checkboxChecked.replaceAll((k,v)->false);

I almost complete the task, just this bug it's stopping me to finish. I appreciate any help, Regards.




Aucun commentaire:

Enregistrer un commentaire