new SearchableDataProvider<Server>(ServerDao.class)) {
private static final long serialVersionUID = 8715559628755439596L;
@Override
protected void populateItem(final Item<Server> item) {
final Server server = item.getModelObject();
item.add(new Label("id", "" + server.getId()));
item.add(new Label("name", "" + server.getName()));
item.add(new Label("address", "" + server.getAddress()));
item.add(new AjaxEventBehavior("onclick") {
private static final long serialVersionUID = -8069413566800571061L;
protected void onEvent(AjaxRequestTarget target) {
form.setModelObject(server);
form.hideNewRecord();
target.add(form, listContainer);
target.appendJavaScript("omServerPanelInit();");
}
});
item.add(AttributeModifier.replace("class", "clickable "
+ (item.getIndex() % 2 == 1 ? "even" : "odd")
+ (server.getId().equals(form.getModelObject().getId()) ? " selected" : "")));
}
};
add(listContainer.add(dataView).setOutputMarkupId(true));
PagedEntityListPanel navigator = new PagedEntityListPanel("navigator", dataView) {
private static final long serialVersionUID = 5097048616003411362L;
@Override
protected void onEvent(AjaxRequestTarget target) {
target.add(listContainer);
}
};
DataViewContainer<Server> container = new DataViewContainer<Server>(listContainer, dataView, navigator);
container.setLinks(new OmOrderByBorder<Server>("orderById", "id", container)
, new OmOrderByBorder<Server>("orderByName", "name", container)
, new OmOrderByBorder<Server>("orderByAddress", "address", container));
add(container.orderLinks);
add(navigator);
form = new ServerForm("form", listContainer, new Server());
form.showNewRecord();
add(form);
}