short addition: possible alternatives: you can use cdi + myfaces codi. in this case serializable proxies will be stored or you can use a session based view-scope [1] or the @ViewAccessScoped itself which is in several use-cases a better solution.
regards, gerhard [1] http://os890.blogspot.com/2011/06/session-based-view-scope-with-codi.html http://www.irian.at Your JSF powerhouse - JSF Consulting, Development and Courses in English and German Professional Support for Apache MyFaces 2011/8/22 Jakob Korherr <[email protected]> > Hi, > > The problem is that dependency injection on managed bean instances via > @ManagedProperty does not work well in @ViewScoped managed beans. This > is because @ViewScoped managed bean instances are serialized and > deserialized in each request, because they are stored in the view > state. Thus the references to the other managed beans are not valid > anymore after deserialization. > > As a workaround you can make those properties transient and query the > right managed bean instance manually via expression language if the > reference is null. > > Regards, > Jakob > > 2011/8/22 Ext-Luhtala Santeri <[email protected]>: > > We have the following situation: > > > > @ManagedBean(name = "BlaBean") > > @ViewScoped > > public class BlaBean implements Serializable { > > > > @ManagedProperty(value = "#{FooBean}") > > private FooBean fooBean; > > } > > > > @ManagedBean(name = "FooBean") > > @SessionScoped > > public class FooBean implements Serializable { > > > > //some members > > //getters setters > > } > > > > @ManagedBean(name = "Bla2Bean") > > @ViewScoped > > public class Bla2Bean implements Serializable { > > > > @ManagedProperty(value = "#{FooBean}") > > private FooBean fooBean; > > } > > > > When we are in the first view of our app we use the BlaBean and the > fooBean and set some values in it and then navigate to next view which uses > Bla2Bean. The values set into fooBean are lost when we get to the second > view. It seems that the FooBean is just instantiated again and not resolved > from session scope. > > > > There are also other managed properties in Bla2Bean and they work. They > are in view scope and custom scope and also one NoneScoped is present. > > > > This works fine with Mojarra 2.0.3. > > > > Thanks in advance > > > > Santeri > > > > > > > > > > -- > Jakob Korherr > > blog: http://www.jakobk.com > twitter: http://twitter.com/jakobkorherr > work: http://www.irian.at >

