wicket serializes the page which contains all the components - so everything your components hold on to is also serialized. this is why we have models that can detach - so you can release the heavy state before the page is serialized, and reacquire it again when needed.
-igor On Thu, Sep 10, 2009 at 7:59 PM, kingcode <jrom...@gmail.com> wrote: > > Thanks Igor for the quick response - I guess this is stating the obvious, but > I conclude that this is just part of the page/component serialization? > > Correct me if I am wrong, but from what I understand the reference to an > outer scope obj. is a 'field' of the inner class and therefore required to > be serializable by wicket. > > JF > > > > igor.vaynberg wrote: >> >>> add new Link( "addToCart") { >>> public void onClick() { >>> getSession().getCart().add( p.getId()); >>> //..etc >>> >> >> your anonymous class keeps a reference to p because inside you >> reference p via p.getId(). >> >> -igor >> >> On Thu, Sep 10, 2009 at 12:00 PM, J.-F. Rompre <jrom...@gmail.com> wrote: >>> Hello, >>> >>> I would like to know where I could find documentation on the issue of >>> serializing objects inherited from a component's container as in the >>> example >>> below. I tried looking at the wicket source code to see when this occurs >>> but >>> still don't understand when/how it is done. >>> >>> //... >>> >>> final Product p = //get non-serializable Product object >>> >>> add new Link( "addToCart") { >>> public void onClick() { >>> getSession().getCart().add( p.getId()); >>> //..etc >>> >>> The above throws a NotSerializableException. However, no problem occurs >>> after the code is changed to: >>> >>> //... >>> >>> //Product p already assigned >>> final String pId = p.getId() //serializable >>> >>> add new Link( "addToCart") { >>> public void onClick() { >>> getSession().getCart().add( pId); >>> //..etc >>> >>> (Also, building the Link with a wrapping Model object also works, >>> obviously) >>> >>> However I am curious to know why a non-model object is serialized when >>> inherited from the container even though within the same request? >>> >>> Thanks for any comment, >>> >>> JF >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> >> >> > > -- > View this message in context: > http://www.nabble.com/Serialization-on-objects-inherited-from-a-container-tp25389127p25394299.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org