Yea, if the environment is per thread then I don't see how it would be
getting env.pop'ed anywhere else manually by my code. As far as my
knowledge goes the loading is something like: Index page loads
Containing Page. Containing page fires BeginRender annotated method
which pushes PageId into the Env. The SubPage then loads. onPrepare of
the SubPage accesses the @Environmental PageId. Return back to the
AfterRender annotated method which pops the PageId from the Env. Now at
this point a form submission can go through and trigger events but the
PageId is now missing from the environment, so an error is thrown...
unless I persisted a reference to the PageId in the SubPage.
That is my current solution.
Here is some debugging info on what gets called when:
Loading the SubPage (DetailsTab) :
[DEBUG] pss.ViewProductTab Pushing PageId id into the Environment in
@BeginRender pushPageId()
[DEBUG] product.DetailsTab Reading @Environmental PageId id in
DetailsTab onPrepare()
[DEBUG] product.DetailsTab Reading @Environmental PageId id in
DetailsTab onPrepare()
[DEBUG] pss.ViewProductTab Popping PageId id from Environment in
@AfterRender popPageId()
Submitting Form (continues from above):
[DEBUG] product.DetailsTab pushing PageId in DetailsTab onPrepareForSubmit
[DEBUG] product.DetailsTab Reading @Environmental PageId id in
DetailsTab onPrepare()
[DEBUG] product.DetailsTab In onSuccessFromForm
If I remove both the Pop and Push methods popPageId() and
onPrepareForSubmit() the following happens:
Loading...
[DEBUG] pss.ViewProductTab Pushing PageId id into the Environment in
@BeginRender pushPageId()
[DEBUG] product.DetailsTab Reading @Environmental PageId id in
DetailsTab onPrepare()
[DEBUG] product.DetailsTab Reading @Environmental PageId id in
DetailsTab onPrepare()
Form submitted...
[DEBUG] product.DetailsTab Reading @Environmental PageId id in
DetailsTab onPrepare()
[ERROR] TapestryModule.RequestExceptionHandler Processing of request
failed with uncaught exception: No object of type
com.moremagic.data.PageId is available from the Environment. Available
types are org.apache.tapestry5.ValidationTracker,
org.apache.tapestry5.services.ComponentEventResultProcessor,
org.apache.tapestry5.services.FormSupport,
org.apache.tapestry5.services.Heartbeat.
As you can see there is no call to env.pop(PageId.class) in this path,
yet after the GET request to the server is sent, the new call to
onPrepare finds no PageId in the environment.
?
-Rich
On 08/23/2010 03:36 PM, Robert Zeigler wrote:
Hm... are you sure you aren't env.pop'ing that PageId somewhere else? It really ought to still be
available in environment in AfterRender. Thiago is correct that you don't /have/ to pop it since
the service is per-thread, but it's disturbing to me that it's not there in AfterRender... unless
one of your SubPage classes is "pop" ing it instead of "peek" ing it?
Robert
On Aug 23, 2010, at 8/2311:50 AM , Thiago H. de Paula Figueiredo wrote:
On Mon, 23 Aug 2010 13:38:14 -0300, Rich M<rich...@moremagic.com> wrote:
I'm assuming you mean in the Containing Page?
Yes.
I tried switching it to onActivate instead of beginRender and in this case the
afterRender method throws a NoSuchElementException when trying to pop the
Object from the Environment, code as below:
//@BeginRender
public void onActivate(){
debug("Loaded ViewProductTab and SubPageId = " + this.id);
env.push(PageId.class, id);
}
@AfterRender
public void popPageId(){
this.id = env.pop(PageId.class);
}
I guess you don't need to pop the object, as Environment is a per-thread
service. And marking a method as handling two different events is not safe in
Tapestry AFAIK.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and
instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org