0

My question is how can i access to a @ViewScoped from another @ViewScoped Bean, i have a ViewScoped which is the controller and in the controller bean i need to get the instance of another bean, a ViewScoped bean which is a Model Bean.

Im trying this but its not working:

FacesContext context = FacesContext.getCurrentInstance();
Modelo.cambiosOperacionBean cambios =(Modelo.cambiosOperacionBean)context.getApplication().evaluateExpressionGet(context, "#{cambiosOperacion}", Modelo.cambiosOperacionBean.class);

it just creates a new instance of the ViewScoped Class, but i need to get the same object and not a new one.

perissf
  • 15,979
  • 14
  • 80
  • 117
Luis Miguel
  • 495
  • 8
  • 22
  • possible duplicate of [Accessing one managed bean from another](http://stackoverflow.com/questions/7204201/accessing-one-managed-bean-from-another) – perissf Apr 19 '14 at 07:11
  • It's logically not possible to do so. There is only one view scoped bean at anytime. But as suggested by BaluC in this example, you pass a view scoped bean via a request attribute and retrieve it another viewscoped bean : [Injecting one view scoped bean in another view scoped bean causes it to be recreated](http://stackoverflow.com/questions/14231044/injecting-one-view-scoped-bean-in-another-view-scoped-bean-causes-it-to-be-recre) –  Apr 19 '14 at 14:51

0 Answers0