I have a list view that has some form components (a checkbox and a
RadioChoice). All of the data from the ListView is getting displayed on the
page properly, but when I try to modify one of the form values, it isn't
getting updated as expected. If anyone has any idea what I might be doing
wrong, please let me know. I have pasted the contents of my code below.
public class MaintainUsersPage extends EzdecBaseWebPage {
@SpringBean
private ISecurityRepository securityRepository;
@SpringBean
private ISecurityService securityService;
private EzdecAccount account;
public class UsersModel extends LoadableDetachableModel {
private EzdecAccount account;
public UsersModel(EzdecAccount account) {
this.account = account;
}
@Override
protected Object load() {
List<EzdecUser> users =
securityRepository.findAllNonArchivedUsersByAccount(account);
return users;
}
}
public MaintainUsersPage() {
add(new FeedbackPanel("feedback"));
account = EzdecSession.getCurrentUser().getAccount();
add(new BookmarkablePageLink("inviteUserLink", InviteUser.class));
add(new Label("accountName", new PropertyModel(account, "name")));
Form form = new Form("maintainUsersForm");
PageableListView users = new PageableListView("users", new
UsersModel(account), 20) {
@Override
protected void populateItem(final ListItem item) {
if (item.getIndex() % 2 == 0) {
item.add(new SimpleAttributeModifier("class", "odd"));
}
final EzdecUser user = (EzdecUser) item.getModelObject();
Link nameLink = new Link("nameLink") {
@Override
public void onClick() {
setResponsePage(new UpdateUserProfilePage(user));
}
};
nameLink.add(new Label("fullname", user.getFullname()));
item.add(nameLink);
item.add(new ExternalLink("emailLink", "mailto:" +
user.getEmail()).add(new Label("email", user.getEmail())));
item.add(new CheckBox("active", new PropertyModel(user,
"active")));
item.add(new RadioChoice("roles",
new PropertyModel(user, "roles"),
Arrays.asList(EzdecRole.values())));
Link deleteLink = new Link("delete") {
@Override
public void onClick() {
if (securityService.archiveUser(user)) {
EzdecSession.get().info("User " +
user.getFullname() + " has been deleted.");
setResponsePage(MaintainUsersPage.class);
} else {
EzdecSession.get().info("User " +
user.getFullname() +
" could not be be deleted. Please ensure that
you " +
" are an account administrator and that you are
" +
" not trying to delete your own account.");
setResponsePage(MaintainUsersPage.class);
}
}
};
deleteLink.add(new SimpleAttributeModifier("onclick",
"return confirm('Are you sure?');"));
item.add(deleteLink);
Link submitLink = new Link("submitLink") {
@Override
public void onClick() {
if (securityService.updateUser(user)) {
EzdecSession.get().info("User " +
user.getFullname() + " has been updated.");
setResponsePage(MaintainUsersPage.class);
} else {
EzdecSession.get().info("User " +
user.getFullname() + " has not been updated.");
setResponsePage(MaintainUsersPage.class);
}
}
};
item.add(submitLink);
}
};
form.add(users);
add(form);
add(new PagingNavigator("navigator", users));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]