And don't forget final scopes:
final Thing thing = component.getModelObject();
add(new Label("this", "that") {
@Override
public boolean isVisible() {
return thing.isGreen();
}
});
For the object "thing" to be accessible in the anonymous inner class
it had to be declared final. Because the Label's isVisible() method
accesses thing, the Label has a reference to thing and thus thing will
be serialized with the Label.
On Wed, Oct 8, 2008 at 7:05 AM, jensiator <[EMAIL PROTECTED]> wrote:
>
> There it was!!!
> If found it with your hint. I was holding in to the reference.
> Thank you.
> Jens Alenius
>
>
>
> igor.vaynberg wrote:
>>
>> if wicket tries to serialize the object you are trying to hold on to a
>> reference of it outside the ldm somewhere in your code. eg
>>
>> object o=ldm.getobject();
>> add(new label("o", o));
>>
>> -igor
>>
>> On Tue, Oct 7, 2008 at 12:21 AM, jensiator <[EMAIL PROTECTED]>
>> wrote:
>>>
>>> Thanks Igor
>>> In my code I started with with a LDM initialized with the modelobject
>>> itself. But it if the modelobject dont implement serializable I get
>>> serialize exception for the modelobject(e.g. contact). My assumption is
>>> that
>>> the modelobject is being serialized to the session. I thought that the
>>> LDM
>>> is a model you use when you dont want to serialize the model to the
>>> session(http://cwiki.apache.org/WICKET/working-with-wicket-models.html#WorkingwithWicketmodels-DetachableModels).
>>> But in the end,as jwcarman wrote, wicket handles the session with disc
>>> writing so it probably no problem. But if its so that the LDM is
>>> serializing
>>> the modelobject in session when you initialize the LDM with it, could I
>>> not
>>> just use a basic Model instead?
>>> Jens Alenius
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Serializing-model.-DetachedModel-or-not-tp19833559p19852478.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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]
>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/Serializing-model.-DetachedModel-or-not-tp19833559p19879431.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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]