});
// 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"));
} catch (Exception e) {
LOGGER.error("Unknown error occured while adding a user to a usergroup", e);
getSession().error(getString("administration.usergroup.members.add.error"));
}
}
userGroupAutocomplete.setModelObject(null);
target.add(getPage());
FeedbackUtils.refreshFeedback(target, getPage());
}
@Override