You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Julio Gonnet <ju...@aquinoes.ch> on 2012/12/04 09:22:18 UTC

Re: Serialization of anonymous classes?

Actually, it can be quite a problem when you pass anonymous classes between
pages/requests. Example: user opens a dialog to search for a specific value
to set in the parent page. the parent page creates and passes an anonymous
callback instance to the dialog, which the dialog calls once the the desired
value has been selected. The callback then theoretically stores the value
somewhere in the parent page's model for further processing. 

But once the Dialog closes and the parent page is refreshed - the value is
nowhere to be seen - doesn't exist. What happened. Well, because of
serialization, the anonymous callback in the dialog holds a reference to the
parent page that has long been serialized. Setting the value within the
callback will not set it in the serialized version, but rather in a
'version' that's attached to the anonymous class that now part of the
dialog. Once the dialog closes, it's all serialized. You now have 2
serialized parent pages, the original and one attached to the dialog via the
anonymous callback. But when refreshing the parent page, it deserializes the
original (the parent page prior to the setting of the value) as it has no
idea of any other version and not the hidden version within the dialog that
has the value set - hence no value to be seen.

This little inconvenience is very hard to detect - cost me a couple of hours
to find! So YES, anonymous classes can cause issues due to serialization!



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Serialization-of-anonymous-classes-tp1843728p4654454.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