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

Reply via email to