});
// Add member form
IModel<User> emptyUserModel = new GenericEntityModel<Long, User>(null);
final UserAutocompleteAjaxComponent userAutocomplete = new UserAutocompleteAjaxComponent("userAutocomplete",
emptyUserModel);
userAutocomplete.setAutoUpdate(true);
final Form<User> addMemberForm = new Form<User>("addFollowerForm", emptyUserModel);
addMemberForm.add(userAutocomplete);
addMemberForm.add(new AjaxSubmitLink("addFollowerLink", addMemberForm) {
private static final long serialVersionUID = 6935376642872117563L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
Artifact artifact = ArtifactFollowersPanel.this.getModelObject();
User selectedUser = userAutocomplete.getModelObject();
if (selectedUser != null) {
try {
userService.followArtifact(selectedUser, artifact);
getSession().success(getString("administration.artifact.followers.add.success"));
} catch (AlreadyFollowedArtifactException e) {
getSession().warn(getString("administration.artifact.followers.add.alreadyFollower"));
} catch (Exception e) {
LOGGER.error("Unknown error occured while following an artifact", e);
getSession().error(getString("administration.artifact.followers.add.error"));
}
}
userAutocomplete.setModelObject(null);
target.add(getPage());
FeedbackUtils.refreshFeedback(target, getPage());
}
@Override