The constructor is the wrong place to do this.

A page is dependant on its engine to access the Visit, 
but the engine will not have been set in the constructor.

Try moving this code to finishLoad().

But remember, the code should work for any number of 
users.

This data, the list of objects, looks transient (only 
needed for the current request cycle). 

If so, the method prepareForRender() is a good place to 
initialize transient properties.  prepareForRender() is 
the last thing called before the page recorders are 
locked down, so its still safe to access the Visit there.

--
[EMAIL PROTECTED]

http://tapestry.sf.net
> Hi,
> 
> I'm having a little trouble getting my head around the Visit object and when
> it's instantiated.  Based on what I've read in the documentation, tapestry
> is designed to delay session creation until the object is absolutely needed.
> This occurs when you make your first call to IPage.getVisit(), correct?
> 
> The problem I'm having is a bit puzzling.  I had every thing working fine,
> until I tried to remove some redundant code.  Originally, I had some
> ActionLinks on a border component that interacted with the visit object,
> then in turn did a fetch to the db and set a list on a browse page.
> Something like:
> 
> public void viewMyObjects(IRequestCycle cycle) {
>       BrowsePage nextPage =
>               (BrowsePage) cycle.getPage("BrowsePage");
> 
>       Visit visit = (Visit) this.getPage().getVisit();
>       DataContext ctxt = visit.getDataContext();
>       .....
>       List objects = ctxt.performQuery(query);
>       nextPage.setList(objects);
>       
>       cycle.setPage(nextPage);
> }
> 
> Instead of building this list in this action method and setting it on the
> following browse page, I decided to make the BrowsePage responsible for
> painting itself.  This is where I run into trouble.  
> 
> I've changed the ActionLink to a 'regular' PageLink in the border component.
> I also removed action method from my border component and added the guts of
> the method to the BrowsePage's constructor.  
> 
> An NullPointerException
> (net.sf.tapestry.AbstractPage.getVisit(AbstractPage.java:380)) is thrown in
> the page's constructor when I call:
> 
> Visit visit = (Visit) this.getPage().getVisit();
> 
> Any ideas?  
> 
> Thanks in advance,
> Eric
> 
> 
> **********************************************************************
> This message, including any attachments, contains confidential information 
> intended for a specific individual and purpose, and is protected by law.  If you 
> are not the intended recipient, please contact sender immediately by reply > e-mail 
>and destroy all copies.  You are hereby notified that any disclosure, 
> copying, or distribution of this message, or the taking of any action based on 
> it, is strictly prohibited.
> TIAA-CREF
> **********************************************************************
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Tapestry-developer mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/tapestry-developer


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Tapestry-developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/tapestry-developer

Reply via email to