public class RestorableViewHandler extends ViewHandlerWrapper
restoreView(FacesContext, String)
returns null
and the current request is a
postback and the view in question has <enableRestorableView>
in the metadata. This effectively
prevents the ViewExpiredException
on the view.
Since OmniFaces 2.2, this view handler implementation also detects unload requests coming from ViewScoped
beans and will only create a dummy view and restore the view scoped state instead of building and restoring the
entire view.
EnableRestorableView
,
ViewScoped
CHARACTER_ENCODING_KEY, DEFAULT_FACELETS_SUFFIX, DEFAULT_SUFFIX, DEFAULT_SUFFIX_PARAM_NAME, DISABLE_FACELET_JSF_VIEWHANDLER_PARAM_NAME, FACELETS_BUFFER_SIZE_PARAM_NAME, FACELETS_DECORATORS_PARAM_NAME, FACELETS_LIBRARIES_PARAM_NAME, FACELETS_REFRESH_PERIOD_PARAM_NAME, FACELETS_SKIP_COMMENTS_PARAM_NAME, FACELETS_SUFFIX_PARAM_NAME, FACELETS_VIEW_MAPPINGS_PARAM_NAME
Constructor and Description |
---|
RestorableViewHandler(ViewHandler wrapped)
Construct a new restorable view handler around the given wrapped view handler.
|
Modifier and Type | Method and Description |
---|---|
ViewHandler |
getWrapped() |
UIViewRoot |
restoreView(FacesContext context,
String viewId)
First check if this is an unload request from
ViewScoped . |
addProtectedView, calculateCharacterEncoding, calculateLocale, calculateRenderKitId, createView, deriveLogicalViewId, deriveViewId, getActionURL, getBookmarkableURL, getProtectedViewsUnmodifiable, getRedirectURL, getResourceURL, getViewDeclarationLanguage, initView, removeProtectedView, renderView, writeState
public RestorableViewHandler(ViewHandler wrapped)
wrapped
- The wrapped view handler.public UIViewRoot restoreView(FacesContext context, String viewId)
ViewScoped
.
If so, then create a dummy view and restore the view scope state. The ViewScopeEventListener
will take
care of actual destroy during PostRestoreStateEvent
.
If not, then restore the view as usual and check if the <o:enableRestoreView>
is used once in
the application, and the restored view is null and the current request is a postback. If not, then return the
restored view unmodified. If so, then recreate and rebuild the view from scratsh. If it indeed contains the
<o:enableRestoreView>
, then return the newly created view, else return null
.restoreView
in class ViewHandlerWrapper
public ViewHandler getWrapped()
getWrapped
in interface FacesWrapper<ViewHandler>
getWrapped
in class ViewHandlerWrapper
Copyright © 2012–2015 OmniFaces. All rights reserved.