If you are certain that detach is always called then you must have
references to the underlying model objects.  I would look through
every call to IModel#getObject().

One thought is that if you create a final variable and refer to that
variable in an anonymous inner class then you have bound the object to
the component.  E.g.

final Foo foo = fooModel.getObject();
add(new Label("id", whatever){public isVisible(){return foo.isPurple();}});
// now foo is bound to the label, and will end up in the session

Scott

On Wed, Aug 26, 2009 at 12:51 PM, Bas Gooren<[email protected]> wrote:
> Sven,
>
> I've been using wicket for over a year, so I'm quite familiar with Model
> usage.
> So thanks for the explanation, but I'm already using CompoundPropertyModels
> and PropertyModels everywhere.
> Because of this it's all the more frustrating to see model contents in my
> session.
>
> Bas
>
> ----- Original Message ----- From: "Sven Meier" <[email protected]>
> To: <[email protected]>
> Sent: Wednesday, August 26, 2009 9:48 PM
> Subject: Re: How to detect model "leakage" into session
>
>
>> Hi,
>>
>> you're probably doing something like the following:
>>
>>  add(new Label("foo", ldm.getObject().getFoo()));
>>
>> Never do that, instead use:
>>
>>  add(new Label("foo", new PropertyModel(ldm, "foo")));
>>
>> ... or ...
>>
>>  add(new Label("foo", new AbstractReadonlyModel() {
>>   public Object getObject() {
>>     return ldm.getObject().getFoo());
>>   }
>>  }));
>>
>> ... or even better ...
>>
>>  setModel(new CompoundPropertyModel(ldm));
>>
>>  add(new Label("foo")); // -> getFoo()
>>  add(new Label("bar")); // -> getBar()
>>  add(new Label("baz")); // -> getBaz()
>>
>> HTH
>>
>> Sven
>>
>> On Mi, 2009-08-26 at 21:29 +0200, Bas Gooren wrote:
>>>
>>> Hi all,
>>>
>>> My problem is as follows: I use LoadableDetachableModels throughout my
>>> application, and have made sure I never use a model without it being
>>> attached to a component to prevent models which never get their detach()
>>> method called.
>>> Nonetheless, after hitting two fairly simple pages which list some
>>> database data in my application, I get a 100kb session which is filled with
>>> literal strings from model objects.
>>>
>>> I've fired up my (Eclipse) debugger and have stepped through all models
>>> on one of the pages after setting a breakpoint on the pages onDetach()
>>> method. I see all LoadableDetachableModels are detached, so I have no idea
>>> what's causing this.
>>>
>>> What would be a good strategy for finding the source of this problem?
>>>
>>> Bas
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to