You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Harry Co <ha...@gmail.com> on 2007/02/07 15:27:29 UTC

Request scope Managed bean instantiated twice

Hello,

I'm facing another odd issue.

I have a managed Bean declared at request scope in my faces-config.xml.
The bean is intended to grap a search result values.
I populate it by an actionListener called within a button (just say #{
serachModel.search}) by calling

public class SearchModel {

//.....members...

public String search(){

String nextView ="result";
FacesContext.current
FacesContext ctx = FacesContext.getCurrentInstance();
MyResultBean myResult=ctx.getApplication
().createValueBinding("#{myResultBean}").getValue(ctx);
myResult.load(...);
return ret;

}

}


(load is a method of MyResultBean receiving a Collection as argument).

My issue is that the bean is once instantiated during *excute* *phase *(that's
ok).
Then another instance is created during RENDER phase causing preloaded
values to be lost.

Have you faced the same?
Any suggestion would be greatly appreciated.

TIA

Harry.

Re: Request scope Managed bean instantiated twice

Posted by Harry Co <ha...@gmail.com>.
Hi Volker,

You are totally right. My navigation rules were redirecting.

I'm going to have a look why all rules declare redirect.

Thanks a lot.

Didier


2007/2/7, Volker Weber <v....@inexso.de>:
>
> Hi,
>
> i never see somthing like this, so just guessing:
> If you use redirect in navigation rules, than you have 2 request for
> each submit, and this is the correct behavior.
>
> Regards,
> Volker
>
> 2007/2/7, Harry Co <ha...@gmail.com>:
> > Hello,
> >
> > I'm facing another odd issue.
> >
> > I have a managed Bean declared at request scope in my faces-config.xml.
> > The bean is intended to grap a search result values.
> > I populate it by an actionListener called within a button (just say
> > #{serachModel.search}) by calling
> >
> > public class SearchModel {
> >
> > //.....members...
> >
> > public String search(){
> >
> > String nextView ="result";
> > FacesContext.current
> > FacesContext ctx = FacesContext.getCurrentInstance();
> > MyResultBean
> > myResult=ctx.getApplication
> ().createValueBinding("#{myResultBean}").getValue(ctx);
> > myResult.load (...);
> > return ret;
> > }
> > }
> >
> > (load is a method of MyResultBean receiving a Collection as argument).
> >
> > My issue is that the bean is once instantiated during excute phase
> (that's
> > ok).
> > Then another instance is created during RENDER phase causing preloaded
> > values to be lost.
> >
> > Have you faced the same?
> > Any suggestion would be greatly appreciated.
> >
> > TIA
> >
> > Harry.
> >
> >
>

Re: Request scope Managed bean instantiated twice

Posted by Volker Weber <v....@inexso.de>.
Hi,

i never see somthing like this, so just guessing:
If you use redirect in navigation rules, than you have 2 request for
each submit, and this is the correct behavior.

Regards,
  Volker

2007/2/7, Harry Co <ha...@gmail.com>:
> Hello,
>
> I'm facing another odd issue.
>
> I have a managed Bean declared at request scope in my faces-config.xml.
> The bean is intended to grap a search result values.
> I populate it by an actionListener called within a button (just say
> #{serachModel.search}) by calling
>
> public class SearchModel {
>
> //.....members...
>
> public String search(){
>
> String nextView ="result";
> FacesContext.current
> FacesContext ctx = FacesContext.getCurrentInstance();
> MyResultBean
> myResult=ctx.getApplication().createValueBinding("#{myResultBean}").getValue(ctx);
> myResult.load(...);
> return ret;
> }
> }
>
> (load is a method of MyResultBean receiving a Collection as argument).
>
> My issue is that the bean is once instantiated during excute phase (that's
> ok).
> Then another instance is created during RENDER phase causing preloaded
> values to be lost.
>
> Have you faced the same?
> Any suggestion would be greatly appreciated.
>
> TIA
>
> Harry.
>
>