Hi,

On Tue, Feb 3, 2015 at 10:14 AM, Thorsten Schöning <tschoen...@am-soft.de>
wrote:

> Guten Tag Sven Meier,
> am Montag, 2. Februar 2015 um 21:03 schrieben Sie:
>
> > You can navigate to a new page instance
> > (#setResponsePage(this.getClass()) if you want to start over with empty
> > input *and* an empty model.
>
> Tried that and indeed the form values are empty in that case, but my
> "success" message is not rendered anymore.
>

Because the success feedback message is associated with a Component that is
not rendered due to the redirect.
You can use getSession().success(...) instead if you know there is a
session, or it is OK to bind one.


>
> Guten Tag Martin Grigorov,
> am Montag, 2. Februar 2015 um 21:59 schrieben Sie:
>
> > Or set a fresh instance as a model object of the Form.
>
> That rendered my "success" message without any old model values. Is
> that a workaround or something one can do without risking problems? It
> feels a bit strange to always create a new form instance which is only
> used as the model, while the first created instance added by the page
> is kept around for the page.
>

I meant to set a new instance of YourEntity in the Form's model. Not to
create a new instance of the Form itself.

Wicket renders the page components by using their models.
After successful submit the Form model object is fully populated and that's
why the form elements have values in the generated markup.
Wicket tries to not do any magic, so it doesn't empty-fy the models
automatically.
Even if Wicket was supposed to make them empty the only possible way is to
set them to null, because Wicket doesn't introspect the object used as a
model object.
Suppose that the Form uses a Person model object. If Wicket sets the person
to null then trying to set his first name with any following submit will
do: null.setFirstName("some new value"). This will lead to
NullPointerException.
Another way is to assume that *your* model objects (i.e. Person class)
always have a default constructor. But Wicket doesn't prescribe how your
model objects should look like.

So after successful submit it is up to the developer to decide what to show
to the end user:
i) a confirmation page
ii) an empty form with success message near by
iii) a populated form
iv) half-populated form

It is really up to *your* use case and wanted user experience


> Would it be a better solution to just empty the only one created
> instance of the form by the page, which I already have anyways and is
> used as default model?
>
> Mit freundlichen Grüßen,
>
> Thorsten Schöning
>
> --
> Thorsten Schöning       E-Mail: thorsten.schoen...@am-soft.de
> AM-SoFT IT-Systeme      http://www.AM-SoFT.de/
>
> Telefon...........05151-  9468- 55
> Fax...............05151-  9468- 88
> Mobil..............0178-8 9468- 04
>
> AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
> AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to