}
}
};
//Adding the Group Form
form = new GroupForm("form", listContainer, new Organisation()){
private static final long serialVersionUID = 1L;
private AjaxButton processAddClass() {
boolean orgSaved = getModelObject().getOrganisation_id() != null;
addUsersBtn.add(AttributeModifier.replace("class", orgSaved ? "formNewButton" : "formNewButton disabled"));
addUsersBtn.setEnabled(orgSaved);
return addUsersBtn;
}
@Override
protected void onModelChanged() {
super.onModelChanged();
processAddClass();
}
@Override
public void updateView(AjaxRequestTarget target) {
super.updateView(target);
target.add(processAddClass());
}
};
add(form.add(addUsersBtn.setOutputMarkupId(true)));
addUsersDialog = new AddUsersDialog("addUsers",WebSession.getString(180), form);
add(addUsersDialog.setOutputMarkupId(true));
//List view
SearchableDataView<Organisation> dataView = new SearchableDataView<Organisation>("groupList", new SearchableDataProvider<Organisation>(OrganisationDao.class)) {
private static final long serialVersionUID = 8715559628755439596L;
@Override
protected void populateItem(Item<Organisation> item) {
final Organisation o = item.getModelObject();
item.add(new Label("organisation_id", "" + o.getOrganisation_id()));
item.add(new Label("name", "" + o.getName()));
item.add(new AjaxEventBehavior("onclick") {
private static final long serialVersionUID = -8069413566800571061L;
protected void onEvent(AjaxRequestTarget target) {
form.hideNewRecord();
form.setModelObject(o);
form.updateView(target);
target.add(listContainer);
target.appendJavaScript("groupsInit();");
}
});
item.add(AttributeModifier.append("class", "clickable "
+ (item.getIndex() % 2 == 1 ? "even" : "odd")
+ (o.getOrganisation_id().equals(form.getModelObject().getOrganisation_id()) ? " selected" : "")));
}
};
//Paging
add(listContainer.add(dataView).setOutputMarkupId(true));