You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Linda van der Pal <lv...@heritageagenturen.nl> on 2009/06/02 12:13:49 UTC
Re: Data getting lost upon form submission
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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Data getting lost upon form submission
Posted by Linda van der Pal <lv...@heritageagenturen.nl>.
No error messages that I can find. It's just that when I fill in the
form, the value gets entered (the role is added to the list). And when I
try to save those values, the values in question (the roles) are gone.
(i.e. the list is empty)
Linda
James Carman wrote:
> Do you see any error messages in the output?
>
> On Tue, Jun 2, 2009 at 6:13 AM, Linda van der Pal
> <lv...@heritageagenturen.nl> wrote:
>
>> 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-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.339 / Virus Database: 270.12.49/2149 - Release Date: 06/01/09 17:55:00
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Data getting lost upon form submission
Posted by James Carman <jc...@carmanconsulting.com>.
Do you see any error messages in the output?
On Tue, Jun 2, 2009 at 6:13 AM, Linda van der Pal
<lv...@heritageagenturen.nl> wrote:
> 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-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org