Package org.omnifaces.viewhandler
Class OmniViewHandler
- java.lang.Object
-
- jakarta.faces.application.ViewHandler
-
- jakarta.faces.application.ViewHandlerWrapper
-
- org.omnifaces.viewhandler.OmniViewHandler
-
- All Implemented Interfaces:
FacesWrapper<ViewHandler>
public class OmniViewHandler extends ViewHandlerWrapper
OmniFaces view handler. This class was before version 2.5 known asRestorableViewHandler
. This view handler performs the following tasks:- Since 1.3: Recreate entire view when
EnableRestorableView
tag is in the metadata. This effectively prevents theViewExpiredException
on the view. - Since 2.2: Detect unload requests coming from
ViewScoped
beans. This will create a dummy view and only restore the view scoped state instead of building and restoring the entire view. - Since 2.5: If project stage is development, then throw an
IllegalStateException
when there's a nestedUIForm
component. - Since 3.10: If
ViewResourceHandler.isViewResourceRequest(FacesContext)
istrue
, then replace the HTML response writer with a XML response writer inrenderView(FacesContext, UIViewRoot)
, and ensure that proper action URL is returned inViewHandlerWrapper.getActionURL(FacesContext, String)
.
- Since:
- 1.3
- Author:
- Bauke Scholtz
- See Also:
EnableRestorableView
,ViewScopeManager
-
-
Field Summary
-
Fields inherited from class jakarta.faces.application.ViewHandler
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 Summary
Constructors Constructor Description OmniViewHandler(ViewHandler wrapped)
Construct a new OmniFaces view handler around the given wrapped view handler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UIViewRoot
createView(FacesContext context, String viewId)
If the current request is a sw.js request fromPWAResourceHandler
, then create a dummy view and triggerFacesContext.responseComplete()
so that it won't be built nor rendered.void
renderView(FacesContext context, UIViewRoot viewToRender)
UIViewRoot
restoreView(FacesContext context, String viewId)
If the current request is an unload request fromViewScoped
, then create a dummy view, restore only the view root state and then immediately explicitly destroy the view, else restore the view as usual.-
Methods inherited from class jakarta.faces.application.ViewHandlerWrapper
addProtectedView, calculateCharacterEncoding, calculateLocale, calculateRenderKitId, deriveLogicalViewId, deriveViewId, getActionURL, getBookmarkableURL, getProtectedViewsUnmodifiable, getRedirectURL, getResourceURL, getViewDeclarationLanguage, getViews, getViews, getWebsocketURL, getWrapped, initView, removeProtectedView, writeState
-
-
-
-
Constructor Detail
-
OmniViewHandler
public OmniViewHandler(ViewHandler wrapped)
Construct a new OmniFaces view handler around the given wrapped view handler.- Parameters:
wrapped
- The wrapped view handler.
-
-
Method Detail
-
createView
public UIViewRoot createView(FacesContext context, String viewId)
If the current request is a sw.js request fromPWAResourceHandler
, then create a dummy view and triggerFacesContext.responseComplete()
so that it won't be built nor rendered.- Overrides:
createView
in classViewHandlerWrapper
-
restoreView
public UIViewRoot restoreView(FacesContext context, String viewId)
If the current request is an unload request fromViewScoped
, then create a dummy view, restore only the view root state and then immediately explicitly destroy the view, else restore the view as usual. If the<o:enableRestoreView>
is used once in the application, and the restored view is null and the current request is a postback, then recreate and rebuild the view from scratch. If it indeed contains the<o:enableRestoreView>
, then return the newly created view, else returnnull
.- Overrides:
restoreView
in classViewHandlerWrapper
-
renderView
public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException
- Overrides:
renderView
in classViewHandlerWrapper
- Throws:
IOException
-
-