Selecting multiple rows
Multiple selection is commonly achieved using groups of checkboxes. One of the most convenient approaches for multiple selections consists of using a special property for tracking the row selection status. This property can be named selected
and it should be of type boolean
(default false
). You can define it in the POJO class as follows:
public class Players { ... private boolean selected; ... public boolean isSelected() { return selected; } public void setSelected(boolean selected) { this.selected = selected; } ...
Note
If your POJO class is an entity class, then define this new property as transient, using the @Transient
annotation or transient modifier. This annotation will tell JPA that this property doesn't participate in persistence and his values are never stored in the database.
Next, assign a checkbox to each row (<h:selectBooleanCheckbox>
). Using the value
attribute and the selected
property, you can easily track the selection status...