public Object saveView(FacesContext context) {
Object result = null;
if (context != null && !context.getViewRoot().isTransient()) {
UIViewRoot viewRoot = context.getViewRoot();
StateManagementStrategy strategy = null;
String viewId = viewRoot.getViewId();
ViewDeclarationLanguage vdl =
context.getApplication().getViewHandler().
getViewDeclarationLanguage(context, viewId);
if (vdl != null) {
strategy = vdl.getStateManagementStrategy(context, viewId);
}
Map<Object, Object> contextAttributes = context.getAttributes();
try {
contextAttributes.put(StateManager.IS_SAVING_STATE, Boolean.TRUE);
if (strategy != null) {
result = strategy.saveView(context);
} else {
strategy = new JspStateManagementStrategy(context);
result = strategy.saveView(context);
}
} finally {
contextAttributes.remove(StateManager.IS_SAVING_STATE);
}
}