On 10/3/07, Martin-2 <[EMAIL PROTECTED]> wrote:
[ CUT on useful suggestions: thanks a lot ]
> The thing is: it's always better to rely on wicket for state handling and
> variable updating. So if two components refer to the same thing, make sure
> your model object is the same for both (or a property of the model object).
> This keeps your data where it belongs (to the model of MVC) and frees you
> from the hassle to deal with update events.

This is what I'm doing indeed: both the ListChoice (which, by the way,
is external to the form) and the panel inside the form are now sharing
the same AbstractModel defined like this:

final IModel recommendationModel = new AbstractModel(){
    public Object getObject(Component component) {
        return currentRecommendation;
    }

    public void setObject(Component component, Object object) {
        currentRecommendation = (Recommendation) object;
    }
};

The ListChoice uses the abstract model directly; the panel uses a
CompoundPropertyModel(recommendationModel) (i.e. over the abstract
one).

What I'm trying to understand is why, when form validation fails, the
CompoundPropertyModel seems to detach from the underlying
AbstractModel and doesn't pass new data to the panel anymore, even if
the AbstractModel correctly keeps getting updated on ListChoice
selection change (I tested it).

This is what I do, basically:

1) Select a choice from the ListChoice;
2) The form automatically fills with the data of the selected
recommendation instance;
3) Modify the data in the form so that validation will fail;
4) Submit data --> validation fails;
5) Select another choice from the ListChoice;
6) The form doesn't get updated anymore (and keeps showing old data of
the recommendation instance that failed validation)

If I come back to choice corresponding to the instance that failed
validation, modify the wrong fields and submit it again, everything
restarts working and the CompoundPropertyModel wakes up again.

> As a last resort, you could put the currentRecommendation to the session,
> the brutal php approach ;)

I'd like to avoid that approach. ;)

> Another thought... The form works until the first time validation failes.
> Check if subsequents submits go through onSubmit().

If I correct inserted data so that validation succeeds, yes,
onSubmit() is executed; otherwise, of course not.


Thanks again for your time and suggestions,

Fabio Fioretti - WindoM

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to