private static final long serialVersionUID = -5179621361619239269L;
@Override
public void onClick(AjaxRequestTarget target) {
try {
UserGroup userGroup = getModelObject();
User user = UserMembershipsPanel.this.getModelObject();
userGroupService.removeUser(userGroup, user);
Session.get().success(getString("administration.usergroup.members.delete.success"));
} catch (Exception e) {
LOGGER.error("Error occured while removing user from user group", e);
Session.get().error(getString("administration.usergroup.members.delete.error"));
}
target.add(getPage());
FeedbackUtils.refreshFeedback(target, getPage());
}
});
}
};
add(userGroupListView);
add(new WebMarkupContainer("emptyList") {
private static final long serialVersionUID = -784607577583169098L;
@Override
public void onConfigure() {
super.onConfigure();
setVisible(userGroupListView.size() <= 0);
}
});
// Add group form
IModel<UserGroup> emptyUserGroupModel = new GenericEntityModel<Long, UserGroup>(null);
final UserGroupAutocompleteAjaxComponent userGroupAutocomplete = new UserGroupAutocompleteAjaxComponent(
"userGroupAutocomplete", emptyUserGroupModel);
userGroupAutocomplete.setAutoUpdate(true);
final Form<UserGroup> addGroupForm = new Form<UserGroup>("addGroupForm", emptyUserGroupModel);
addGroupForm.add(userGroupAutocomplete);
addGroupForm.add(new AjaxSubmitLink("addGroupLink", addGroupForm) {
private static final long serialVersionUID = 6935376642872117563L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
User user = UserMembershipsPanel.this.getModelObject();
UserGroup selectedUserGroup = userGroupAutocomplete.getModelObject();
if (selectedUserGroup != null) {
try {
userGroupService.addUser(selectedUserGroup, user);
getSession().success(getString("administration.usergroup.members.add.success"));