You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Dave <ja...@yahoo.com> on 2006/10/04 11:41:31 UTC

FacesContext currentInstance changed from Invoke Application to Render phase

Hello,
   
  I have a manage bean (named "fooBean") declared in faces-config.xml, and tried to get the JSF managed bean instance for a request/response cycle when a commandButton is clicked.
   
  The code:
   
    FacesContext context = FacesContext.getCurrentInstance();
  FooBean bean = (FooBean)context.getApplication ().getVariableResolver().resolveVariable(context, "fooBean");
   
  During Invoke Application phase, the fooBean was one instance. However when the cycle went to Render phase, 
   
          FacesContext.getCurrentInstance()  had a different value, and returned a new fooBean instance.  
   
  Is this a bug?   FacesContext instance:  one per Http request( or per thread) ?
  I need to have the same fooBean instance for the whole request/response cycle.
   
  I am using MyFaces 1.1.4. and  Tomahawk 1.1.3.
  Any help will be appreciated.
   
  Thanks.
  Dave
   
          


 		
---------------------------------
How low will we go? Check out Yahoo! Messenger’s low  PC-to-Phone call rates.

Re: FacesContext currentInstance changed from Invoke Application to Render phase

Posted by Volker Weber <we...@googlemail.com>.
what exactly did you mean by 'after page navigation' ?

on navigation without redirect the request scope beans will live
fromfirst access until end of renderResponse phase.

you may look at tomahawks saveState tag:
http://myfaces.apache.org/tomahawk/uiSaveState.html



2006/10/6, Dave <ja...@yahoo.com>:
> After debugging, I found that a new FacesContext instance is created and all
> backing beans are initialized after page navigation.
>
> In my case, during invoke application phase I prepare an backing bean(JSF
> managed) that I expect it to be used by another page after page navigation.
>
> The managed beans defined in faces-config.xml are request scope, and they
> should
> servive even after navigating to a different page.
>
> Should it have a new scope like "page scope"?
>
> Thanks,
> Dave
>
>
> Volker Weber <we...@googlemail.com> wrote:
> Hi Dave,
>
> did you use redirect navigation rules? than you will get two requests
> on the server for one request from the client.
>
> 2006/10/4, Dave :
> > Hello,
> >
> > I have a manage bean (named "fooBean") declared in faces-config.xml, and
> > tried to get the JSF managed bean instance for a request/response cycle
> when
> > a commandButton is clicked.
> >
> > The code:
> >
> > FacesContext context = FacesContext.getCurrentInstance();
> > FooBean bean = (FooBean)context.getApplication
> > ().getVariableResolver().resolveVariable(context,
> > "fooBean");
> >
> > During Invoke Application phase, the fooBean was one instance. However
> when
> > the cycle went to Render phase,
> >
> > FacesContext.getCurrentInstance() had a different value, and
> > returned a new fooBean instance.
> >
> > Is this a bug? FacesContext instance: one per Http request( or per
> > thread) ?
> > I need to have the same fooBean instance for the whole request/response
> > cycle.
> >
> > I am using MyFaces 1.1.4. and Tomahawk 1.1.3.
> > Any help will be appreciated.
> >
> > Thanks.
> > Dave
> >
> >
> >
> >
> > ________________________________
> > How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call
> rates.
> >
> >
>
>
>
>  ________________________________
> Do you Yahoo!?
>  Get on board. You're invited to try the new Yahoo! Mail.
>
>

Re: FacesContext currentInstance changed from Invoke Application to Render phase

Posted by Dave <ja...@yahoo.com>.
After debugging, I found that a new FacesContext instance is created and all backing beans are initialized after page navigation.
   
  In my case, during invoke application phase I prepare an backing bean(JSF managed) that I expect it to be used by another page after page navigation.
   
  The managed beans defined in faces-config.xml are request scope, and they should
  servive even after navigating to a different page. 
   
  Should it have a new scope like "page scope"?
   
  Thanks,
  Dave
  

Volker Weber <we...@googlemail.com> wrote:
  Hi Dave,

did you use redirect navigation rules? than you will get two requests
on the server for one request from the client.

2006/10/4, Dave :
> Hello,
>
> I have a manage bean (named "fooBean") declared in faces-config.xml, and
> tried to get the JSF managed bean instance for a request/response cycle when
> a commandButton is clicked.
>
> The code:
>
> FacesContext context = FacesContext.getCurrentInstance();
> FooBean bean = (FooBean)context.getApplication
> ().getVariableResolver().resolveVariable(context,
> "fooBean");
>
> During Invoke Application phase, the fooBean was one instance. However when
> the cycle went to Render phase,
>
> FacesContext.getCurrentInstance() had a different value, and
> returned a new fooBean instance.
>
> Is this a bug? FacesContext instance: one per Http request( or per
> thread) ?
> I need to have the same fooBean instance for the whole request/response
> cycle.
>
> I am using MyFaces 1.1.4. and Tomahawk 1.1.3.
> Any help will be appreciated.
>
> Thanks.
> Dave
>
>
>
>
> ________________________________
> How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call rates.
>
>


 		
---------------------------------
Do you Yahoo!?
 Get on board. You're invited to try the new Yahoo! Mail.

Re: FacesContext currentInstance changed from Invoke Application to Render phase

Posted by Volker Weber <we...@googlemail.com>.
Hi Dave,

did you use redirect navigation rules? than you will get two requests
on the server for one request from the client.

2006/10/4, Dave <ja...@yahoo.com>:
> Hello,
>
> I have a manage bean (named "fooBean") declared in faces-config.xml, and
> tried to get the JSF managed bean instance for a request/response cycle when
> a commandButton is clicked.
>
> The code:
>
>   FacesContext context = FacesContext.getCurrentInstance();
>   FooBean bean = (FooBean)context.getApplication
> ().getVariableResolver().resolveVariable(context,
> "fooBean");
>
> During Invoke Application phase, the fooBean was one instance. However when
> the cycle went to Render phase,
>
>         FacesContext.getCurrentInstance()  had a different value, and
> returned a new fooBean instance.
>
> Is this a bug?   FacesContext instance:  one per Http request( or per
> thread) ?
> I need to have the same fooBean instance for the whole request/response
> cycle.
>
> I am using MyFaces 1.1.4. and  Tomahawk 1.1.3.
> Any help will be appreciated.
>
> Thanks.
> Dave
>
>
>
>
>  ________________________________
> How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call rates.
>
>