lets say that we have a facelet view index.xhtml with following command links:
If I follow the first command link PreDestroyViewMapEvent will fire, but if I follow the second one it won
>>>>> On Mon, 28 Jun 2010 10:16:11 PDT, email@example.com said:
P> lets say that we have a facelet view [b]index.xhtml[/b] with
P> following command links:
P> If I follow the first command link PreDestroyViewMapEvent will fire,
P> but if I follow the second one it won'tt. So, I was wondering does
P> anyone know if there is a reason for this difference in behavior.
This is because in the first case, you are doing a POSTBACK, which
causes the navigation to happen during the invoke application phase,
which changes the viewId stored in the FacesContext during the POSTBACK
In the second case, you're doing a POST REDIRECT GET, which encompases
multiple runs through the lifecycle, each with its own FacesContext
Let's look at the HTTP traffic in both cases.
POST index.xhtml run lifecycle phases APPLY_REQUEST_VALUES upto
and including INVOKE_APPLICATION on one
During INVOKE_APPLICATION, a new UIViewRoot is
created as a result of the navigation. It
happens have the same viewId because you
manually specify "index" as your action, but
it's a new UIViewRoot just the same. When this
viewId is populated into the FacesContext, the
viewMap is destroyed.
Run RENDER_RESPONSE phase, send response to client
POST index.xhtml same as above, but do not run RENDER_RESPONSE
phase. Instead send 302 redirect.
GET index.html This is a new request, with a new FacesContext,
so we don't get the viewmap destroyed event.
| edburns... | office: +1 407 458 0017
| homepage: | http://ridingthecrest.com/
| 13 Work Days Til JSF 2.1 Milestone 1
To unsubscribe, e-mail: firstname.lastname@example.org
For additional commands, e-mail: email@example.com
I agree with everything stated above, so I'll try to rephrase my question in light of your answer.
> Client Server
> POST index.xhtml same as above, but do not run RENDER_RESPONSE
> phase. Instead send 302 redirect.
I've observed that in POST run of PRG when redirect 302 is sent, PreDestroyViewMapEvent is fired every time except when redirect is targeting the same page. So, why is that? Why PreDestroyViewMapEvent isn't fired only when PRG is targeting the same page from which it has originated? Hope I've made more sense this time. :)
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Participation.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.