dev@javaserverfaces.java.net

Re: INVOKE_APPLICATION PhaseListener with redirect

From: Matt Benson <gudnabrsam_at_gmail.com>
Date: Wed, 19 Oct 2011 15:29:02 -0500

On Wed, Oct 19, 2011 at 2:41 PM, Ed Burns <edward.burns_at_oracle.com> wrote:
>>>>>> On Wed, 19 Oct 2011 11:50:23 -0500, Matt Benson <gudnabrsam_at_gmail.com> said:
>
> [...]
>
> MB> These have the effect of allowing afterPhase() to be triggered while
> MB> the request is active.
>
> [...]
>
> This is the key thing.  The rest is implementation details (ha!).  But
> seriously, are you ok with having a special case that makes the
> "afterPhase()" listeners be invoked "early" in the case of a redirect?
> More specifically, when ExternalContext.redirect() is called, any
> afterPhase() listeners for the current phase must be executed
> immediately, before the underlying servlet or portlet redirect methods
> are invoked, or, in the case of ajax, any of the special ajax actions
> are taken.
>
> Is this ok?

I think I have talked myself around to your approach as far as the
spec goes, the final reason being that redirect is properly a function
of the ExternalContext. When you're wrapping the ExternalContext,
it's okay IMO to snatch a call away from the "real" impl and deliver
it later, but handling it in this way IN the "real" impl would only
result in a bumpier API (to differentiate between "redirect later" and
"redirect now"), and certainly the simplicity of the interface
outweighs that of the implementation. The only other approach would
be to make the "redirect later" call against the FacesContext, with
the implementation calling "redirect now" against the ExternalContext
at the proper time, but this would break clients currently calling
ExternalContext.redirect() directly. While I would prefer this design
given a clean slate, that's not what we're working with here.

Thanks for the talk; do you need me to create the JIRA request?

Matt

>
> Ed
>
> --
> | edward.burns_at_oracle.com | office: +1 407 458 0017
> | homepage:               | http://ridingthecrest.com/
>