users@javaserverfaces.java.net

RE: Re: How do I use the NavigationHandler.public void beforePhase(PhaseEvent event){?

From: Todd Patrick <Todd.Patrick_at_dtn.com>
Date: Mon, 23 Jul 2007 15:26:07 -0500

I really don't understand this.

I found that the ExternalContext.redirect() method calls
FacesContext.responseComplete(), so I moved my logic into the mananged
bean's constructor:

    public ClientBean() {
        FacesContext facesContext = this.getFacesContext();
        AdfFacesContext afContext =
AdfFacesContext.getCurrentInstance();
        Logger log = Logger.getLogger(ClientBean.class);
        
        try {
            this.selectedClient = (ClientDetail)
afContext.getProcessScope().get("clientKey");
            if(this.selectedClient != null) {
                this.clientKey = this.selectedClient.getClientKey();
                this.passwordResultList.clear();
            } else {
 
facesContext.getExternalContext().redirect("/client/manage/clientsearch.
jsp");
            }
        } catch (IOException ex) {
            log.error("ClientBean redirection error. ", ex);
        }
    }

In Netbeans 5.5.1 I can step over the statement in the managed bean
constructor:

facesContext.getExternalContext().redirect("/client/manage/clientsearch.
jsp");


But, the page continues to render and no redirection happens. Any
thoughts on this would be greatful and very much welcomed.

Thanks,

--Todd Patrick

-----Original Message-----
From: Ryan.Lubke_at_Sun.COM [mailto:Ryan.Lubke_at_Sun.COM]
Sent: Monday, July 23, 2007 1:18 PM
To: users_at_javaserverfaces.dev.java.net
Subject: Re: How do I use the NavigationHandler.public void
beforePhase(PhaseEvent event){?

Todd Patrick wrote:
> I have a view beforePhase attribute attached to the following method:
>
> public void beforePhase(PhaseEvent event){
> Logger log = Logger.getLogger(ClientBean.class);
> log.info(event.getPhaseId().toString());
>
> FacesContext facesContext = this.getFacesContext();
> AdfFacesContext afContext =
> AdfFacesContext.getCurrentInstance();
>
> if(ObjectUtils.equals(afContext.getProcessScope().get("clientKey"),
> null)){
> Application application = facesContext.getApplication();
> NavigationHandler nav =
application.getNavigationHandler();
> nav.handleNavigation(facesContext, null, "clientsearch");
> }
> }
>
>
I believe you should add facesContext.responseComplete() before calling
handleNavigation().

> I am stepping into the if control-flow statement as I debug this in
> Netbeans 5.5.1.
>
> What I don't understand is how do I use the handleNavigation method
> properly?
>
> When I step over this statement, the page continues to load and the
> user is not redirected to the page attached to the JSF navigation-case

> "clientsearch" does not render.
>
> I'd appreciate any thoughts or help with this.
>
> Thanks,
>
> --Todd Patrick
>
> -----------------------------------------
> NOTICE: This email message is for the sole use of the intended
> recipient(s) and may contain confidential and privileged information.
> Any unauthorized use, disclosure or distribution is prohibited. If you

> are not the intended recipient, please contact the sender by reply
> email and destroy all copies of the original message.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail:
> users-help_at_javaserverfaces.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_javaserverfaces.dev.java.net
For additional commands, e-mail: users-help_at_javaserverfaces.dev.java.net