You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by dlutowskik <dl...@microinput.com> on 2013/09/19 10:43:28 UTC

Wicket Models Questions

I have two questions about models in Wicket.
1. In some panel I have IModel<List&lt;Object>> objectModel or IModel
objectModel and this model is created as
LoadableDetachableModel<List&lt;Object>> or LoadableDetachableModel. Is it
good approach? If yes do I need to detach this model in onDetach() method?
2. I have two panels A and B. Panel B is created in panel A and it needed
some model. In panel A there is empty object. How should I create model with
this empty object - new Model(new Object()), new LoadableDetachableModel() {
.. load() {return new Object()}}? In which panel should I detach this model
in Panel B in which this model is used or in Panel A in which this model was
created?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Models-Questions-tp4661393.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Wicket Models Questions

Posted by Sven Meier <sv...@meiers.net>.
> 1

If your component holds a reference to a model, then it is responsible to detach it:

   public void detachModels() {
     super.detachModels();

     this.objectModel.detach();
   }

In most cases you can use each model as the default model of some component, so detachment is taken care of automatically:

   public SomePanel(String id, IModel<List<Object>> model) {
     super(id, model);
   }

> 2

new Model(...) is fine if you want to keep the model object serialized along with the component. LoadableDetachableModel is recommended if you are able to re-load the model object from somewhere in the next request.
Panel B should detach the model, since the model was passed to the Panel and it can't know whether the outside will keep a reference to it.
Panel A doesn't have to detach the model, since it can expect Panel B to take care of that.

Regards
Sven

On 09/19/2013 10:43 AM, dlutowskik wrote:
> I have two questions about models in Wicket.
> 1. In some panel I have IModel<List&lt;Object>> objectModel or IModel
> objectModel and this model is created as
> LoadableDetachableModel<List&lt;Object>> or LoadableDetachableModel. Is it
> good approach? If yes do I need to detach this model in onDetach() method?
> 2. I have two panels A and B. Panel B is created in panel A and it needed
> some model. In panel A there is empty object. How should I create model with
> this empty object - new Model(new Object()), new LoadableDetachableModel() {
> .. load() {return new Object()}}? In which panel should I detach this model
> in Panel B in which this model is used or in Panel A in which this model was
> created?
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Models-Questions-tp4661393.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


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