columns.add(new PropertyColumn(new ResourceModel("firstName"), "firstName", "firstName"));
columns.add(new PropertyColumn(new ResourceModel("lastName"), "lastName", "lastName"));
columns.add(new PropertyColumn(new ResourceModel("homePhone"), "homePhone"));
columns.add(new PropertyColumn(new ResourceModel("cellPhone"), "cellPhone"));
final DataGrid grid = new DefaultDataGrid("grid", new ContactDataSource(), columns) {
private static final long serialVersionUID = 1L;
@Override
public void onItemSelectionChanged(IModel item, boolean newValue) {
super.onItemSelectionChanged(item, newValue);
// when item selection changes the label showing selected items needs to be
// refreshed
AjaxRequestTarget target = AjaxRequestTarget.get();
target.addComponent(selectionLabel);
}
};
add(grid);
grid.setCleanSelectionOnPageChange(false);
grid.setClickRowToSelect(true);
grid.setRowsPerPage(15);
// model for label that shows selected items
IModel selectedItemsModel = new Model() {
private static final long serialVersionUID = 1L;