SearchableDataView<Room> dataView = new SearchableDataView<Room>("roomList", new SearchableDataProvider<Room>(RoomDao.class)) {
private static final long serialVersionUID = 8715559628755439596L;
@Override
protected void populateItem(final Item<Room> item) {
final Room room = item.getModelObject();
item.add(new Label("rooms_id", "" + room.getRooms_id()));
item.add(new Label("name", "" + room.getName()));
item.add(new Label("ispublic", "" + room.getIspublic()));
item.add(new AjaxEventBehavior("onclick") {
private static final long serialVersionUID = -8069413566800571061L;
protected void onEvent(AjaxRequestTarget target) {
form.hideNewRecord();
form.setModelObject(room);
form.updateView(target);
target.add(form, listContainer);
target.appendJavaScript("omRoomPanelInit();");
}
});
item.add(AttributeModifier.replace("class", "clickable "
+ (item.getIndex() % 2 == 1 ? "even" : "odd")
+ (room.getRooms_id().equals(form.getModelObject().getRooms_id()) ? " selected" : "")));
}
};
add(listContainer.add(dataView).setOutputMarkupId(true));
PagedEntityListPanel navigator = new PagedEntityListPanel("navigator", dataView) {
private static final long serialVersionUID = -1L;
@Override
protected void onEvent(AjaxRequestTarget target) {
target.add(listContainer);
}
};
DataViewContainer<Room> container = new DataViewContainer<Room>(listContainer, dataView, navigator);
container.setLinks(new OmOrderByBorder<Room>("orderById", "rooms_id", container)
, new OmOrderByBorder<Room>("orderByName", "name", container)
, new OmOrderByBorder<Room>("orderByPublic", "ispublic", container));
add(container.orderLinks);
add(navigator);
final AjaxButton addModerator = new AjaxButton("addModerator") {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
addModeratorsDialog.open(target);
}
};
form = new RoomForm("form", listContainer, new Room()){
private static final long serialVersionUID = 3186201157375166657L;
@Override
protected void onModelChanged() {
super.onModelChanged();