You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Steve Swinsburg <s....@lancaster.ac.uk> on 2009/04/02 13:17:11 UTC

back button, deserialisation and readObject()

All,

I have some questions regarding deserialization. On a page in my  
application, I click a link which takes me to a different page, then  
click 'back', and try to do something on the original page, but get  
NPE's whenever any of my transient fields are called. A simple example:

private transient Logger log = Logger.getLogger(BasePage.class);

Later in my code I use my log object in the onSubmit of a button:

log.debug("MySearch() search.getSearchInterest(): " + searchText);

Which works fine in the normal workings of the page. If I click away  
from the page then use the 'back' button to come back to this page,  
then click the button that will call this same log.debug statement,  
thats when the NPE occurs.

So, am I correct in my understanding that the page is serialized when  
I click away, de-serialized when I come back, and, since no transient  
objects are serialized along with it, that my 'log' will be null and  
this NPE is then correct?

If so, this leads me to thinking that, in order for my page to set  
itself up again correctly, I need to override readObject() and re- 
setup all of my transient objects that would not be restored in this  
method? Is this a good or bad practice?

It is working correctly I am just after any tips or caveats.

ie this works:

private void readObject(ObjectInputStream in) throws IOException,  
ClassNotFoundException {
	// our "pseudo-constructor"
	in.defaultReadObject();
	// now we are a "live" object again, so let's rebuild
	log = Logger.getLogger(BasePage.class);
}


thanks a lot,
Steve


p.s.
Of interest, when I click 'back' in Safari 4, the whole page is  
reconstructed again (ie the constructor is called again) and  
readObject is not called, but in other browsers, the state is  
preserved and readObject() is called. Not sure what the go is with that.

ref: http://java.sun.com/developer/technicalArticles/Programming/serialization/









Re: London Wicket Event 01/04/09

Posted by nino martinez wael <ni...@gmail.com>.
Put up a webcam, and record thru that.. Video migth not be the best
but i'll be there.. I'll bring one if I come :) But right now, I can't
justify it for my manager :( Now if there where something about wicket
and VoiceXML it could be possible :)

2009/4/2 James Carman <jc...@carmanconsulting.com>:
> Ok, we've got a volunteer to do the transcoding/editing.  Anyone
> available to offer up recording equipment?  I'd be willing to donate
> some cash to the project if it comes to that.
>
> On Thu, Apr 2, 2009 at 9:14 AM, Yiannis Mavroukakis
> <im...@gameaccount.com> wrote:
>> I've pestered Cemal about it, as the (in)frequency of the event means that
>> if someone cannot
>> make it they have to wait for 2 months..I haven't got a camera/audio
>> recording equipment myself but I'd be more than willing to do any necessary
>> transcoding/editing and stick them on a webserver.
>>
>> Y.
>>
>> James Carman wrote:
>>>
>>> It would be great if these events were video taped somehow (podcast?).
>>>  For those of us in the US, we feel left out :(
>>>
>>>
>>> On Thu, Apr 2, 2009 at 9:09 AM, Martijn Dashorst
>>> <ma...@gmail.com> wrote:
>>>
>>>>
>>>> It definitely is an event worth visiting. I had a blast, and enjoyed
>>>> every minute of it (except for travelling back at 5am).
>>>>
>>>> Great crowd, finally being able to meet, greet, and drink beers with
>>>> luminaries such as Cemal and Al.
>>>>
>>>> I hope we can create such an atmosphere over the world for the Wicket
>>>> events.
>>>>
>>>> Martijn
>>>>
>>>> (feeling quite tired now after ~3 hours of sleep)
>>>>
>>>> On Thu, Apr 2, 2009 at 1:27 PM, Yiannis Mavroukakis
>>>> <im...@gameaccount.com> wrote:
>>>>
>>>>>
>>>>> Just wanted to thank everyone involved for another excellent evening
>>>>>  :-)
>>>>> The presentations from everyone were very informative, I especially
>>>>> enjoyed
>>>>> Martijn Dashorst's presentation of what can be achieved with Wicket, and
>>>>> Al
>>>>> Maw for the fastest trying-to-drum-API-sense-into-you tutorial ever ;-)
>>>>>
>>>>> Ioannis.
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> Become a Wicket expert, learn from the best: http://wicketinaction.com
>>>> Apache Wicket 1.3.5 is released
>>>> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: London Wicket Event 01/04/09

Posted by James Carman <jc...@carmanconsulting.com>.
Ok, we've got a volunteer to do the transcoding/editing.  Anyone
available to offer up recording equipment?  I'd be willing to donate
some cash to the project if it comes to that.

On Thu, Apr 2, 2009 at 9:14 AM, Yiannis Mavroukakis
<im...@gameaccount.com> wrote:
> I've pestered Cemal about it, as the (in)frequency of the event means that
> if someone cannot
> make it they have to wait for 2 months..I haven't got a camera/audio
> recording equipment myself but I'd be more than willing to do any necessary
> transcoding/editing and stick them on a webserver.
>
> Y.
>
> James Carman wrote:
>>
>> It would be great if these events were video taped somehow (podcast?).
>>  For those of us in the US, we feel left out :(
>>
>>
>> On Thu, Apr 2, 2009 at 9:09 AM, Martijn Dashorst
>> <ma...@gmail.com> wrote:
>>
>>>
>>> It definitely is an event worth visiting. I had a blast, and enjoyed
>>> every minute of it (except for travelling back at 5am).
>>>
>>> Great crowd, finally being able to meet, greet, and drink beers with
>>> luminaries such as Cemal and Al.
>>>
>>> I hope we can create such an atmosphere over the world for the Wicket
>>> events.
>>>
>>> Martijn
>>>
>>> (feeling quite tired now after ~3 hours of sleep)
>>>
>>> On Thu, Apr 2, 2009 at 1:27 PM, Yiannis Mavroukakis
>>> <im...@gameaccount.com> wrote:
>>>
>>>>
>>>> Just wanted to thank everyone involved for another excellent evening
>>>>  :-)
>>>> The presentations from everyone were very informative, I especially
>>>> enjoyed
>>>> Martijn Dashorst's presentation of what can be achieved with Wicket, and
>>>> Al
>>>> Maw for the fastest trying-to-drum-API-sense-into-you tutorial ever ;-)
>>>>
>>>> Ioannis.
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>> --
>>> Become a Wicket expert, learn from the best: http://wicketinaction.com
>>> Apache Wicket 1.3.5 is released
>>> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: London Wicket Event 01/04/09

Posted by Yiannis Mavroukakis <im...@gameaccount.com>.
I've pestered Cemal about it, as the (in)frequency of the event means 
that if someone cannot
make it they have to wait for 2 months..I haven't got a camera/audio 
recording equipment myself but I'd be more than willing to do any 
necessary transcoding/editing and stick them on a webserver.

Y.

James Carman wrote:
> It would be great if these events were video taped somehow (podcast?).
>  For those of us in the US, we feel left out :(
>
>
> On Thu, Apr 2, 2009 at 9:09 AM, Martijn Dashorst
> <ma...@gmail.com> wrote:
>   
>> It definitely is an event worth visiting. I had a blast, and enjoyed
>> every minute of it (except for travelling back at 5am).
>>
>> Great crowd, finally being able to meet, greet, and drink beers with
>> luminaries such as Cemal and Al.
>>
>> I hope we can create such an atmosphere over the world for the Wicket events.
>>
>> Martijn
>>
>> (feeling quite tired now after ~3 hours of sleep)
>>
>> On Thu, Apr 2, 2009 at 1:27 PM, Yiannis Mavroukakis
>> <im...@gameaccount.com> wrote:
>>     
>>> Just wanted to thank everyone involved for another excellent evening  :-)
>>> The presentations from everyone were very informative, I especially enjoyed
>>> Martijn Dashorst's presentation of what can be achieved with Wicket, and Al
>>> Maw for the fastest trying-to-drum-API-sense-into-you tutorial ever ;-)
>>>
>>> Ioannis.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>       
>>
>> --
>> Become a Wicket expert, learn from the best: http://wicketinaction.com
>> Apache Wicket 1.3.5 is released
>> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: London Wicket Event 01/04/09

Posted by James Carman <jc...@carmanconsulting.com>.
It would be great if these events were video taped somehow (podcast?).
 For those of us in the US, we feel left out :(


On Thu, Apr 2, 2009 at 9:09 AM, Martijn Dashorst
<ma...@gmail.com> wrote:
> It definitely is an event worth visiting. I had a blast, and enjoyed
> every minute of it (except for travelling back at 5am).
>
> Great crowd, finally being able to meet, greet, and drink beers with
> luminaries such as Cemal and Al.
>
> I hope we can create such an atmosphere over the world for the Wicket events.
>
> Martijn
>
> (feeling quite tired now after ~3 hours of sleep)
>
> On Thu, Apr 2, 2009 at 1:27 PM, Yiannis Mavroukakis
> <im...@gameaccount.com> wrote:
>>
>> Just wanted to thank everyone involved for another excellent evening  :-)
>> The presentations from everyone were very informative, I especially enjoyed
>> Martijn Dashorst's presentation of what can be achieved with Wicket, and Al
>> Maw for the fastest trying-to-drum-API-sense-into-you tutorial ever ;-)
>>
>> Ioannis.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
>
> --
> Become a Wicket expert, learn from the best: http://wicketinaction.com
> Apache Wicket 1.3.5 is released
> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: London Wicket Event 01/04/09

Posted by Martin Funk <ma...@googlemail.com>.
If you would have taken of at 14:35
you would have had time to drop by the tate galery.
:-)

beyond that I'd also like to thank Cemal and Al organizing that event  
and even helping with peoples traveling plans.
I wonder how many people would have showed up if the G20 were not  
arround.

Thank you guys!

mf

Am 02.04.2009 um 15:09 schrieb Martijn Dashorst:

> It definitely is an event worth visiting. I had a blast, and enjoyed
> every minute of it (except for travelling back at 5am).
>
> Great crowd, finally being able to meet, greet, and drink beers with
> luminaries such as Cemal and Al.
>
> I hope we can create such an atmosphere over the world for the  
> Wicket events.
>
> Martijn
>
> (feeling quite tired now after ~3 hours of sleep)
>
> On Thu, Apr 2, 2009 at 1:27 PM, Yiannis Mavroukakis
> <im...@gameaccount.com> wrote:
>>
>> Just wanted to thank everyone involved for another excellent  
>> evening  :-)
>> The presentations from everyone were very informative, I especially  
>> enjoyed
>> Martijn Dashorst's presentation of what can be achieved with  
>> Wicket, and Al
>> Maw for the fastest trying-to-drum-API-sense-into-you tutorial  
>> ever ;-)
>>
>> Ioannis.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
>
> -- 
> Become a Wicket expert, learn from the best: http://wicketinaction.com
> Apache Wicket 1.3.5 is released
> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: London Wicket Event 01/04/09

Posted by Martijn Dashorst <ma...@gmail.com>.
It definitely is an event worth visiting. I had a blast, and enjoyed
every minute of it (except for travelling back at 5am).

Great crowd, finally being able to meet, greet, and drink beers with
luminaries such as Cemal and Al.

I hope we can create such an atmosphere over the world for the Wicket events.

Martijn

(feeling quite tired now after ~3 hours of sleep)

On Thu, Apr 2, 2009 at 1:27 PM, Yiannis Mavroukakis
<im...@gameaccount.com> wrote:
>
> Just wanted to thank everyone involved for another excellent evening  :-)
> The presentations from everyone were very informative, I especially enjoyed
> Martijn Dashorst's presentation of what can be achieved with Wicket, and Al
> Maw for the fastest trying-to-drum-API-sense-into-you tutorial ever ;-)
>
> Ioannis.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.5 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


London Wicket Event 01/04/09

Posted by Yiannis Mavroukakis <im...@gameaccount.com>.
Just wanted to thank everyone involved for another excellent evening  
:-) The presentations from everyone were very informative, I especially 
enjoyed Martijn Dashorst's presentation of what can be achieved with 
Wicket, and Al Maw for the fastest trying-to-drum-API-sense-into-you 
tutorial ever ;-)

Ioannis.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: back button, deserialisation and readObject()

Posted by Martijn Dashorst <ma...@gmail.com>.
Use a loadable detachable model instead (see also wicket in action,
chapter re models). and in page.ondetach() detach those models.

Martijn

On Thu, Apr 2, 2009 at 1:27 PM, Steve Swinsburg
<s....@lancaster.ac.uk> wrote:
> Thanks Martijn,
>
> Understand re logger and making it a static instance, but what about other
> transient fields, is it ok to override getObject on each page an re setup my
> transient fields or is this going to cause issues down the track?
>
>
> cheers,
> Steve
>
>
>
>
>
> On 2 Apr 2009, at 12:22, Martijn Dashorst wrote:
>
>> magic word for loggers: static
>>
>> and your assumption is correct: if you don't do anything, you'll get
>> NPE's when you reference a transient field on an object that has been
>> deserialized.
>>
>> Martijn
>>
>> On Thu, Apr 2, 2009 at 1:17 PM, Steve Swinsburg
>> <s....@lancaster.ac.uk> wrote:
>>>
>>> All,
>>> I have some questions regarding deserialization. On a page in my
>>> application, I click a link which takes me to a different page, then
>>> click
>>> 'back', and try to do something on the original page, but get NPE's
>>> whenever
>>> any of my transient fields are called. A simple example:
>>> private transient Logger log = Logger.getLogger(BasePage.class);
>>> Later in my code I use my log object in the onSubmit of a button:
>>> log.debug("MySearch() search.getSearchInterest(): " + searchText);
>>> Which works fine in the normal workings of the page. If I click away from
>>> the page then use the 'back' button to come back to this page, then click
>>> the button that will call this same log.debug statement, thats when the
>>> NPE
>>> occurs.
>>> So, am I correct in my understanding that the page is serialized when I
>>> click away, de-serialized when I come back, and, since no transient
>>> objects
>>> are serialized along with it, that my 'log' will be null and this NPE is
>>> then correct?
>>> If so, this leads me to thinking that, in order for my page to set itself
>>> up
>>> again correctly, I need to override readObject() and re-setup all of my
>>> transient objects that would not be restored in this method? Is this a
>>> good
>>> or bad practice?
>>> It is working correctly I am just after any tips or caveats.
>>> ie this works:
>>> private void readObject(ObjectInputStream in) throws IOException,
>>> ClassNotFoundException {
>>> // our "pseudo-constructor"
>>> in.defaultReadObject();
>>> // now we are a "live" object again, so let's rebuild
>>> log = Logger.getLogger(BasePage.class);
>>>
>>> }
>>>
>>> thanks a lot,
>>> Steve
>>>
>>> p.s.
>>> Of interest, when I click 'back' in Safari 4, the whole page is
>>> reconstructed again (ie the constructor is called again) and readObject
>>> is
>>> not called, but in other browsers, the state is preserved and
>>> readObject()
>>> is called. Not sure what the go is with that.
>>> ref:
>>> http://java.sun.com/developer/technicalArticles/Programming/serialization/
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>> --
>> Become a Wicket expert, learn from the best: http://wicketinaction.com
>> Apache Wicket 1.3.5 is released
>> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.5 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: back button, deserialisation and readObject()

Posted by Steve Swinsburg <s....@lancaster.ac.uk>.
Thanks Martijn,

Understand re logger and making it a static instance, but what about  
other transient fields, is it ok to override getObject on each page an  
re setup my transient fields or is this going to cause issues down the  
track?


cheers,
Steve





On 2 Apr 2009, at 12:22, Martijn Dashorst wrote:

> magic word for loggers: static
>
> and your assumption is correct: if you don't do anything, you'll get
> NPE's when you reference a transient field on an object that has been
> deserialized.
>
> Martijn
>
> On Thu, Apr 2, 2009 at 1:17 PM, Steve Swinsburg
> <s....@lancaster.ac.uk> wrote:
>> All,
>> I have some questions regarding deserialization. On a page in my
>> application, I click a link which takes me to a different page,  
>> then click
>> 'back', and try to do something on the original page, but get NPE's  
>> whenever
>> any of my transient fields are called. A simple example:
>> private transient Logger log = Logger.getLogger(BasePage.class);
>> Later in my code I use my log object in the onSubmit of a button:
>> log.debug("MySearch() search.getSearchInterest(): " + searchText);
>> Which works fine in the normal workings of the page. If I click  
>> away from
>> the page then use the 'back' button to come back to this page, then  
>> click
>> the button that will call this same log.debug statement, thats when  
>> the NPE
>> occurs.
>> So, am I correct in my understanding that the page is serialized  
>> when I
>> click away, de-serialized when I come back, and, since no transient  
>> objects
>> are serialized along with it, that my 'log' will be null and this  
>> NPE is
>> then correct?
>> If so, this leads me to thinking that, in order for my page to set  
>> itself up
>> again correctly, I need to override readObject() and re-setup all  
>> of my
>> transient objects that would not be restored in this method? Is  
>> this a good
>> or bad practice?
>> It is working correctly I am just after any tips or caveats.
>> ie this works:
>> private void readObject(ObjectInputStream in) throws IOException,
>> ClassNotFoundException {
>> // our "pseudo-constructor"
>> in.defaultReadObject();
>> // now we are a "live" object again, so let's rebuild
>> log = Logger.getLogger(BasePage.class);
>>
>> }
>>
>> thanks a lot,
>> Steve
>>
>> p.s.
>> Of interest, when I click 'back' in Safari 4, the whole page is
>> reconstructed again (ie the constructor is called again) and  
>> readObject is
>> not called, but in other browsers, the state is preserved and  
>> readObject()
>> is called. Not sure what the go is with that.
>> ref: http://java.sun.com/developer/technicalArticles/Programming/serialization/
>>
>>
>>
>>
>>
>>
>>
>>
>
>
>
> -- 
> Become a Wicket expert, learn from the best: http://wicketinaction.com
> Apache Wicket 1.3.5 is released
> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


Re: back button, deserialisation and readObject()

Posted by Martijn Dashorst <ma...@gmail.com>.
magic word for loggers: static

and your assumption is correct: if you don't do anything, you'll get
NPE's when you reference a transient field on an object that has been
deserialized.

Martijn

On Thu, Apr 2, 2009 at 1:17 PM, Steve Swinsburg
<s....@lancaster.ac.uk> wrote:
> All,
> I have some questions regarding deserialization. On a page in my
> application, I click a link which takes me to a different page, then click
> 'back', and try to do something on the original page, but get NPE's whenever
> any of my transient fields are called. A simple example:
> private transient Logger log = Logger.getLogger(BasePage.class);
> Later in my code I use my log object in the onSubmit of a button:
> log.debug("MySearch() search.getSearchInterest(): " + searchText);
> Which works fine in the normal workings of the page. If I click away from
> the page then use the 'back' button to come back to this page, then click
> the button that will call this same log.debug statement, thats when the NPE
> occurs.
> So, am I correct in my understanding that the page is serialized when I
> click away, de-serialized when I come back, and, since no transient objects
> are serialized along with it, that my 'log' will be null and this NPE is
> then correct?
> If so, this leads me to thinking that, in order for my page to set itself up
> again correctly, I need to override readObject() and re-setup all of my
> transient objects that would not be restored in this method? Is this a good
> or bad practice?
> It is working correctly I am just after any tips or caveats.
> ie this works:
> private void readObject(ObjectInputStream in) throws IOException,
> ClassNotFoundException {
> // our "pseudo-constructor"
> in.defaultReadObject();
> // now we are a "live" object again, so let's rebuild
> log = Logger.getLogger(BasePage.class);
>
> }
>
> thanks a lot,
> Steve
>
> p.s.
> Of interest, when I click 'back' in Safari 4, the whole page is
> reconstructed again (ie the constructor is called again) and readObject is
> not called, but in other browsers, the state is preserved and readObject()
> is called. Not sure what the go is with that.
> ref: http://java.sun.com/developer/technicalArticles/Programming/serialization/
>
>
>
>
>
>
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.5 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org