On Fri, May 28, 2010 at 5:06 PM, Benedikt Schlegel <
[email protected]> wrote:
> Hello wicket ppl,
>
> im pretty new in wicket and im facing a problem which seems to me like im
> missing some basic understanding here.
>
> I have a form which is supposed to fill a filter object. So i add some
> TextFields with property models, based on that object, to the form (actually
> to a WebMarkupContainer which is a child of the form).
> Then i have two AjaxButtons to 'apply' and reset the filter. I added an
> aditional (debug) container with a Label which displays the content of the
> filter object.
>
> When i enter some information in the TextFields and click apply, the object
> gets updated and so does the 'debug label'. Then i push the reset button and
> want the filter object to be nulled and the TextFields to be cleared. But
> only the object gets affected, the TextFields dont get updated (cleared).
>
> Some code:
>
> filterContainer.add(new TextField<FilterObject>("filterFoo", new
> PropertyModel<PersonFilter>(filter, "foo")));
> filterContainer.add(new TextField<FilterObject>("filterBar", new
> PropertyModel<PersonFilter>(filter, "bar")));
>
> filterContainer.add(new AjaxButton("filterApply", new
> Model<String>("apply")) {
> @Override
> protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
> target.addComponent(debugContainer);
> }
> });
>
> filterContainer.add(new AjaxButton("filterReset", new
> Model<String>("reset")) {
> @Override
> protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
> filter = new FilterObject();
> target.addComponent(debugContainer);
> target.addComponent(filterContainer);
> }
> });
>
> Any suggestions? I would appreciate any kind of help on that.
>
> So long,
> Benedikt
> [Beta Systems Disclaimer/Impressum: http://www.betasystems.com/disclaimer]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
You're replacing the filter, but the (old) filter is already held (passed
into) in your property models. You have two options:
1 - Add a reset() method to your PersonFilter and call that instead of
replacing it with a new one.
2 - Make your filter variable an IModel<PersonFilter> that holds the actual
filter object. Then pass this model into your property models (where you're
currently passing in the actual filter object). Then call
filter.setObject(new PersonFilter())
--
Jeremy Thomerson
http://www.wickettraining.com