You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Hill, Joel (DTMB)" <Hi...@michigan.gov> on 2012/05/17 16:18:44 UTC

Nested Form submitted via ajax clearing fields in outer form

If I have a nested form submitted via an AjaxButton, why does it call onFormSubmitted for the root form?  Is this the way it has to be programmed for nested forms to work?

The problem is that if I refresh any part of the page that contains a FormComponent in the outer form, that field gets cleared, because the rawInput gets set to null (because inputChanged gets called for all the outer form components).

Is the answer that I just have to be more surgical in my use of AjaxRequestTarget.addComponent, and only add components that REALLY need to be redrawn, and not just redraw a larger area (which requires fewer addComponent calls)?  I know that calling clearInput on every component in the outer form in the refreshed area(s) will also work, but that seems a less appropriate solution (I guess there is Form.clearInput as well, which is less labor intensive to use).

I guess this is more of an informational question than anything.  But any solutions that require less babysitting of the outer form are welcome.  Thanks!

Joel

Re: Nested Form submitted via ajax clearing fields in outer form

Posted by Sebastien <se...@gmail.com>.
Hi,

> why does it call onFormSubmitted for the root form?  Is this the way it
has to be programmed for nested forms to work?
Well, I think it should not be the case, according to:
https://cwiki.apache.org/WICKET/nested-forms.html

Regards,
Sebastien.

On Thu, May 17, 2012 at 4:18 PM, Hill, Joel (DTMB) <Hi...@michigan.gov>wrote:

> If I have a nested form submitted via an AjaxButton, why does it call
> onFormSubmitted for the root form?  Is this the way it has to be programmed
> for nested forms to work?
>
> The problem is that if I refresh any part of the page that contains a
> FormComponent in the outer form, that field gets cleared, because the
> rawInput gets set to null (because inputChanged gets called for all the
> outer form components).
>
> Is the answer that I just have to be more surgical in my use of
> AjaxRequestTarget.addComponent, and only add components that REALLY need to
> be redrawn, and not just redraw a larger area (which requires fewer
> addComponent calls)?  I know that calling clearInput on every component in
> the outer form in the refreshed area(s) will also work, but that seems a
> less appropriate solution (I guess there is Form.clearInput as well, which
> is less labor intensive to use).
>
> I guess this is more of an informational question than anything.  But any
> solutions that require less babysitting of the outer form are welcome.
>  Thanks!
>
> Joel
>