problems with multiple row operations in a dataTable
Dear fellows,
I have a strange problem, i want to do multiple row deletion in a dataTable. Can any one tell me a better way to do it. Because the way i am doing it, it is causing me strange problems. In some places it start working and in some it dont.
The way i am doing it, it has the following code:
<h:form>
<h:dataTable id="list" value="#{availableRoomsList}" var="RoomTypes" >
<h:column>
<f:facet name="header">
<h:outputText value="Select"/>
</f:facet>
<h:selectBooleanCheckbox value="#{roomSelection[RoomTypes]}" >
</h:selectBooleanCheckbox>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Available Date"/>
</f:facet>
<h:outputText value="#{RoomTypes.availableDate}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Available Rooms"/>
</f:facet>
<h:outputText value="#{RoomTypes.noOfRooms}"/>
</h:column>
</h:dataTable>
<h:commandButton value="delete Selected Rooms" action="#{RoomResvAction.deleteRooms}" />
</h:form>
Now the back end code that i am using is as follows:
private List<HotelRoomTypes> availableRoomsList;
Map<HotelRoomTypes, Boolean> roomSelection =new HashMap<HotelRoomTypes, Boolean>();
/*--*/
public String deleteRoom(){
System.out.println("In the delete selection method aad.");
try{
for (HotelRoomTypes item: availableRoomsList){
Boolean selected = roomSelection.get(item);
if (selected!=null && selected){
roomSelection.put(item,false);
//deleteRoom(item);
}
}
}catch(Exception e){
//e.printStackTrace();
}
returnnull;
}
The problem with the JSF code is when i click the command button it do not calls the associated action method with it. i dont know what is the problem with the code.
And as far as the backend code is concern it should work fine.
can anybody help me on this matter.

