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) {
Room room = item.getModelObject();
final long roomId = room.getRooms_id();
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(getBean(RoomDao.class).get(roomId));
form.updateView(target);
target.add(form, listContainer);
target.appendJavaScript("omRoomPanelInit();");
}
});
item.add(AttributeModifier.replace("class", "clickable ui-widget-content"
+ (room.getRooms_id().equals(form.getModelObject().getRooms_id()) ? " ui-state-active" : "")));
}
};
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.addLink(new OmOrderByBorder<Room>("orderById", "rooms_id", container))
.addLink(new OmOrderByBorder<Room>("orderByName", "name", container))
.addLink(new OmOrderByBorder<Room>("orderByPublic", "ispublic", container));
add(container.getLinks());
add(navigator);
add(form = new RoomForm("form", listContainer, new Room()));
}