You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by sean chen <se...@yahoo.com> on 2004/05/11 02:50:33 UTC

Can I use method getVisit() in a page's initialize() method?

Hi,
 
I use the following code to set the initial values for properties of a page.  Those initial values are stored in the Visit Object.
 
public void initialize() {
    
    MyVisit visit = (MyVisit) getVisit();
    _amount = visit.getAmount();
   .....
}
 
But when I activated this page, I got the java.lang.NullPointerException:
 

com.xpointc.jia.album.AlbumBrowser.initialize(AlbumBrowser.java:49) 
org.apache.tapestry.AbstractPage.<init>(AbstractPage.java:124) 
org.apache.tapestry.html.BasePage.<init>(BasePage.java:32)
......

So, can I use the getVisit() method in the page's initialize() method?

If I need get values from Visit Object during a page initialization, How to do it?

 

Thanks

 

Sean

		
---------------------------------
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs 

Re: Can I use method getVisit() in a page's initialize() method?

Posted by Jamie Orchard-Hays <ja...@dang.com>.
First thing to understand: initialize() is not for initializing the 
properties on your page. A bit confusing. initialize() is the state you 
want the page to be in when you are done with it and it is returned to 
the page pool--usually you set properties to null. (This is done 
automatically if you define them in the .page file.)

The proper place to initialize is in pageBeginRender(). Make sure you 
implement PageRenderListener and override this method.

If your page has a form or a link that has a listener make sure you 
check for the rewind if you don't want to getVisit() again during the 
rewind.

Jamie

On May 10, 2004, at 8:50 PM, sean chen wrote:

> Hi,
>
> I use the following code to set the initial values for properties of a 
> page.  Those initial values are stored in the Visit Object.
>
> public void initialize() {
>
>     MyVisit visit = (MyVisit) getVisit();
>     _amount = visit.getAmount();
>    .....
> }
>
> But when I activated this page, I got the 
> java.lang.NullPointerException:
>
>
> com.xpointc.jia.album.AlbumBrowser.initialize(AlbumBrowser.java:49)
> org.apache.tapestry.AbstractPage.<init>(AbstractPage.java:124)
> org.apache.tapestry.html.BasePage.<init>(BasePage.java:32)
> ......
>
> So, can I use the getVisit() method in the page's initialize() method?
>
> If I need get values from Visit Object during a page initialization, 
> How to do it?
>
>
>
> Thanks
>
>
>
> Sean
>
> 		
> ---------------------------------
> Do you Yahoo!?
> Win a $20,000 Career Makeover at Yahoo! HotJobs 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org