Serialization ManagedProperty

We have the following problem with JSF @ViewScopedand @ManagedProperty: we have ManagedBean, which basically look like this:

@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 processing the request, as expected. I expected that it @ManagedProperty sessionConfigwould be processed specifically in serialization, in particular, that after deserialization it would be “re-enabled”. However, it turns out that after deserialization sessionConfigis just an outdated clone of the actual SessionConfig-Bean.

Questions:

  • Is this expected behavior?
  • What can we do to make the JSF reevaluate @ManagedPropertyafter deserialization?

We are currently “manually” re-evaluating all managed properties after deserialization. It works, but obviously does not seem to be correct.

Thank!

+2
1

, @ManagedProperty @ViewScoped beans EL . @ViewScoped beans (, , ) .

FacesContext ctx = FacesContext.getCurrentInstance();
ctx.getApplication().evaluateExpressionGet(ctx, "#{sessionConfig}", SessionConfig.class)

, , .

aproach , : http://www.oracle.com/technetwork/articles/java/javaserial-1536170.html , bean.

0

All Articles