Each component can have as many models it needs. For an example see ListChoice which has one model for its selection and a second one for the available choices.

Wicket's Component base class has a default model, which offers convenience (it's automatically detached after request) and some other goodies (i.e. inherited models).

Read more here: https://cwiki.apache.org/WICKET/working-with-wicket-models.html

>Page#setDefaultModel( new PropertyModel( this, "user" ) ); And then in on* methods,
>I should use getPage().getDefaultModelObject().

Models offer no magic: Doing the above versus just directly accessing the page's property doesn't change much (depending on what "this" is referring to).

>Is that correct, or should I look for some other bug in my code?

Your components are probably holding references to different User objects. Cleaning up your code using models might help.

Sven


On 09/29/2012 05:26 AM, Ondrej Zizka wrote:
Hi,

I have observed that if I simply refer to Page object's (say, User)
member field everywhere, sometimes I get a strange behavior:
Ajax requests update the User object properly. But then I have non-ajax
save (submit) button, and this one actually saves the old state of the
object, before editations.

I get it I am supposed to use models in this case, like,
Page#setDefaultModel( new PropertyModel( this, "user" ) );
And then in on* methods, I should use getPage().getDefaultModelObject().

Is that correct, or should I look for some other bug in my code?

And also, what does the "default" mean in  the methods names
getDefaultModel*() ? Can the page/component have multiple models?

Thanks,
Ondra




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to