You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Dr. Wolf Blecher" <wo...@itk-engineering.de> on 2010/04/28 15:41:43 UTC

BreadcrumbPanel Form Model

Hi everybody,

For the last two days I'm stumbling around the following problem.
I have a BreadCrumbPanel (UserEditPanel) and a form inside this panel.
In the form there are two textfields (Name, ChristianName),  a
DropDownChoice (role), a link (Edit Roles) and two buttons (Save, Cancel).
The idea is that I change something in the textfields, click on the
editRolesLink, a new BreadCrumbPanel is opened, where I can add some
Roles, and when I return to the EditUserPanel the CHANGED values are in
the text fields instead of the ORIGINAL values.

At the moment I am doing the following:
On creation of the UserEditPanel I am assigning the modelObject that is
passed via the constructor to a local variable user.
The form gets as default model a new CompoundPropertyModel with this
local variable:

userEditForm.setDefaultModel(new CompoundPropertyModel<User>(user));

The values of the variable are correctly filled in the TextFields, so
adding my textfields works fine.

If I change something in the Textfields, click the Save Button (which
submits the form) and I set my values to user.getName() etc. the changed
values are taken, so the values of the local user variable are updated.

But when I click on the BreadCrumbPanelLink (which does not submit the
form by default), the original values are restored in the textfields
when I come back to the UserEditPanel.
So I tried to overwrite the onClick Method of the BreadCrumbPanelLink to
start a form processing (which should do nothing except storing changed
values from the model in the local user variable since I did not
overwrite the onSubmit method of the form)
the values of my local user variable are set to null.

One possible solution I was thinking of is that instead of using
userEditForm.add(new TextField("vorname"))
I write
TextField vorname = new Textfield("vorname");
userEditForm.add(vorname);
and in the onClick Method of the BreadCrumbPanelLink I use
user.setVorname(vorname.getInput());

but as far as I understood models correctly, this should not be
necessary. But where is the missing link?

Regards

Wolf


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: BreadcrumbPanel Form Model

Posted by "Dr. Wolf Blecher" <wo...@itk-engineering.de>.
I'm not quite sure if this is the perfect way of doing this, but here is
a workaround:

Instead of placing a BreadCrumbPanelLink, I placed a SubmitLink and in
the onSubmit method I use the "IBreadCrumbPanelFactory-Method" to create
the new BreadCrumbPanel.
So the form gets submitted (which is needed to update the model) and the
new BreadCrumbPanel is created and after returning the changed values
are still alive.

Cheers

Wolf


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org