We have the following problem with JSF's @ViewScoped
and @ManagedProperty
: we have ManagedBean
s that basically look as follows:
@ManagedBean
@SessionScope
public class SessionConfig implements Serializable
{
// ...
}
and
@ManagedBean
@ViewScope
public class SomeController implements Serializable
{
@ManagedProperty( value="#{sessionConfig}" )
private SessionConfig sessionConfig;
// public getter and setter
// ...
}
The controller is serialized after the request has been processed, as expected.
I expected that the @ManagedProperty
sessionConfig
would be handled specially in serialization, in particular, that it will be "relinked" after deserialization. However, it turns out that after deserialization sessionConfig
is merely a stale clone of the actual SessionConfig-Bean.
Questions:
- Is this the expected behavior?
- What can we do to make JSF re-evaluate the
@ManagedProperty
after deserialization?
Currently, we "manually" re-evaluate all managed properties after deserialzation. It works but, clearly does not seem right.
Thank you!