I just thought of something, might this be a serialization problem? And
if so, any clue on how I can solve it?
Linda.
Linda van der Pal wrote:
Forgot to copy this line (which came just before the start of the form):
setDefaultModel(new CompoundPropertyModel<User>(user));
Linda van der Pal wrote:
I am once again making some error in my thinking. I'm trying to edit
a user in a form, but for some reason not all the values are passed
on upon submitting. Can anybody have a look and point me in the right
direction?
When I save the data I can see the name and the password, but not the
roles. I have debugged it and I see that it actually puts the roles
in an instance of User, but when I get to the code that actually
saves it all, the roles are empty again. (So they have been put in a
different instance, but why and how?)
Here's the form:
// The form
Form<User> form = new Form<User>("userdetailform");
add(form);
// The name-field
form.add(new TextField<String>("name").setRequired(true));
// The roles-field
CheckGroup rolesGroup = new CheckGroup("roles");
CheckBox ownerRole = new CheckBox("owner");
rolesGroup.add(ownerRole);
form.add(rolesGroup);
And here's the User class (name is a variable in DomainObject):
public class User extends DomainObject {
private String password;
private List<Role> roles;
public User(final Integer id) {
super(id);
roles = new ArrayList<Role>();
}
public void setPassword(final String password) {
this.password = password;
}
public String getPassword() {
return password;
}
public void setRoles(final List<Role> roles) {
this.roles = roles;
}
public List<Role> getRoles() {
return roles;
}
public void addRole(final Role role) {
this.roles.add(role);
}
private boolean hasRole(final RoleName roleName) {
for (Role role: roles) {
if (role.getName().equals(roleName)) {
return true;
}
}
return false;
}
public boolean isOwner() {
return hasRole(RoleName.OWNER);
}
private void setRole(final RoleName roleName, final Integer
friendId, final boolean addRole) {
Role role = new Role(roleName, friendId);
if (addRole) {
addRole(role);
} else {
this.roles.remove(role);
}
}
public void setOwner(final boolean addRole) {
setRole(RoleName.OWNER, null, addRole);
}
}
Regards,
Linda
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG - www.avg.com Version: 8.5.339 / Virus Database:
270.12.44/2140 - Release Date: 05/28/09 18:09:00
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.339 / Virus Database: 270.12.44/2140 - Release Date: 05/28/09 18:09:00
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org