On Tue, Jul 20, 2010 at 1:55 AM, Ray Weidner <
ray.weidner.develo...@gmail.com> wrote:

> Hi all,
>
> I have what I would think to be a fairly common usecase that I'd like to
> solve.  I have a form with a model that is a LoadableDetachableModel
> wrapped
> in a CompoundPropertyModel.  I wouldn't expect that to be unusual.
>  However,
> when a form submit is failing validation for , all changes to the form are
> lost.  I'm guessing that the LoadableDetachableModel, when combined with
> the
> blocked update to the model, is causing this.
>
> For the most part, I've been able to get around this by "deferring" most
> validation checks until #onSubmit, at which point I manually run through
> them and call #error on the appropriate components.
>
> Two problems: First, I can't defer all validation.  Type conversions and
> the
> size of uploaded files are validated automatically, and you wouldn't want
> to
> have to rewrite that for yourself.  Second, I don't want to defer all the
> validation.  In so doing, I lose the benefits of Wicket handling all that
> stuff in the back end for me.
>
> I'm wondering if there's a possible work-around.  What if, during the call
> to #onError, I was to call #updateModel?  The javadoc gives a rather
> significant warning against using this method, but I'm wondering if it has
> some value here.  The point is, if I force the model to be updated despite
> the validation failure, then changes will not be lost upon submission.
>
> Any thoughts?
>

Don't use a LoadableDetachableModel for a form.

-- 
Jeremy Thomerson
http://www.wickettraining.com

Reply via email to