> 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 <[email protected]> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to