@Override
public UIViewRoot restoreView(FacesContext context,
String viewId,
String renderKitId) {
ResponseStateManager rsm =
RenderKitUtils.getResponseStateManager(context, renderKitId);
boolean processingEvents = context.isProcessingEvents();
// Build the tree to initial state
UIViewRoot viewRoot;
try {
ViewDeclarationLanguage vdl = vdlFactory.getViewDeclarationLanguage(viewId);
viewRoot = vdl.getViewMetadata(context, viewId).createMetadataView(context);
context.setViewRoot(viewRoot);
context.setProcessingEvents(true);
vdl.buildView(context, viewRoot);
} catch (IOException ioe) {
throw new FacesException(ioe);
}
Object[] rawState = (Object[]) rsm.getState(context, viewId);
if (rawState == null) {
return null; // trigger a ViewExpiredException
}
//noinspection unchecked
final Map<String, Object> state = (Map<String,Object>) rawState[1];