This probably is NOT the solution, as this method gets executed only once
when the page is loaded and added to the pool.

Multiple users and hundreds of requests can be served with only one call to
PageLoaded, if I understand it correctly.

The pageAttached and pageDetached events occur when the page is fetched from
the pool (attach) and returned back (detach). This occurs once per request.

The best solution that I can come up is to use additional context parameter
to simulate the activateExternalPage(), so when you use page link or similar
you can "notify" the page correctly.

I mean

onActivate(Long key, boolean fromAnotherPage) {
  //Do activateExternalPage() stuff
}

onActivate(Long key){
  if(noInitializationYetDone){
    //do normal initialization
  }
}

onPassivate(){
  return key;
}

This way the normal page flow does the normal initialization on form
postbacks etc, and the special initialization can be done if the link that
directs to the page contains the magic boolean in the context.

However, this should be avoided by design, so that page can initialize
itself correctly without stale checks imho, so no data in session etc. (I
don't know how Cayenne works so this might not apply, but I've noticed that
this is best practise for our apps w/ hibernate.)

 - Ville


JoelGrrrr wrote:
> 
> This might help... PageLoaded ... 
> http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/annotations/PageLoaded.html
> 
> 
> 
> -----Original Message-----
> From: Bryan Lewis <jbryanle...@gmail.com>
> Reply-To: Tapestry users <users@tapestry.apache.org>
> To: users@tapestry.apache.org
> Subject: once-only onActivate method
> Date: Sun, 19 Apr 2009 22:18:10 -0400
> 
> I need a method that will get called exactly once when a page is first
> invoked, and not again when a form in the page is submitted.  In Tapestry
> 4
> the activateExternalPage() method was good for that.  I don't think the
> new
> onActivate() method is a replacement, nor is the SetupRender-annotated
> method.  For example, they get called when an autocomplete textfield is
> used
> in mid-form.  How do I do this in Tap 5?  (My intent is to clear any stale
> changes in my Cayenne DataContext.)
> 
> Thanks.
> 
> -- 
> Joel Halbert
> 020 3051 8637
> 075 2501 0825
> j...@storequery.com
> www.storequery.com
> SU3 Analytics Ltd, The Print House, 18 Ashwin St, London E8 3DL.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/once-only-onActivate-method-tp23129460p23141937.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to