target.appendJavaScript("addUsers();");
}
});
//Adding the Group Form
form = new GroupForm("form", listContainer, new Organisation()){
private static final long serialVersionUID = -3042797340375988889L;
@Override
protected void onModelChanged() {
super.onModelChanged();
boolean orgEmpty = getModelObject().getOrganisation_id() == null;
if (orgEmpty) {
addUsersBtn.add(AttributeModifier.replace("class", "formNewButton disabled"));
} else {
addUsersBtn.add(AttributeModifier.replace("class", "formNewButton"));
}
addUsersBtn.setEnabled(!orgEmpty);
addUsersForm.setOrganisation(getModelObject());
}
@Override
void updateView(AjaxRequestTarget target) {
super.updateView(target);
target.add(addUsersBtn);
}
};
add(form.add(addUsersBtn.setOutputMarkupId(true)));
addUsersForm = new AddUsersForm("addUsers", form);
add(addUsersForm);
//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 organisation = item.getModelObject();
item.add(new Label("organisation_id", "" + organisation.getOrganisation_id()));
item.add(new Label("name", "" + organisation.getName()));
item.add(new AjaxEventBehavior("onclick") {
private static final long serialVersionUID = -8069413566800571061L;
protected void onEvent(AjaxRequestTarget target) {
form.hideNewRecord();