jakarta.faces.application.ViewHandlerWrapper Maven / Gradle / Ivy
/*
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package jakarta.faces.application;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;
import jakarta.faces.FacesException;
import jakarta.faces.FacesWrapper;
import jakarta.faces.component.UIViewRoot;
import jakarta.faces.context.FacesContext;
import jakarta.faces.view.ViewDeclarationLanguage;
/**
*
* Provides a simple implementation of {@link ViewHandler} that can be
* subclassed by developers wishing to provide specialized behavior to an existing {@link ViewHandler} instance. The
* default implementation of all methods is to call through to the wrapped {@link ViewHandler}.
*
*
*
* Usage: extend this class and push the implementation being wrapped to the constructor and use {@link #getWrapped} to
* access the instance being wrapped.
*
*
* @since 1.2
*/
public abstract class ViewHandlerWrapper extends ViewHandler implements FacesWrapper {
private ViewHandler wrapped;
/**
*
* If this view handler has been decorated, the implementation doing the decorating should push the implementation being
* wrapped to this constructor. The {@link #getWrapped()} will then return the implementation being wrapped.
*
*
* @param wrapped The implementation being wrapped.
* @since 2.3
*/
public ViewHandlerWrapper(ViewHandler wrapped) {
this.wrapped = wrapped;
}
@Override
public ViewHandler getWrapped() {
return wrapped;
}
// ------------------------ Methods from jakarta.faces.application.ViewHandler
/**
*
* The default behavior of this method is to call {@link ViewHandler#initView} on the wrapped {@link ViewHandler}
* object.
*
*
* @see ViewHandler#initView
* @since 1.2
*/
@Override
public void initView(FacesContext context) throws FacesException {
getWrapped().initView(context);
}
/**
*
* The default behavior of this method is to call
* {@link ViewHandler#restoreView(jakarta.faces.context.FacesContext, String)} on the wrapped {@link ViewHandler}
* object.
*
*
* @see ViewHandler#restoreView(jakarta.faces.context.FacesContext, String)
* @since 1.2
*/
@Override
public UIViewRoot restoreView(FacesContext context, String viewId) {
return getWrapped().restoreView(context, viewId);
}
/**
*
* The default behavior of this method is to call
* {@link ViewHandler#createView(jakarta.faces.context.FacesContext, String)} on the wrapped {@link ViewHandler} object.
*
*
* @see ViewHandler#createView(jakarta.faces.context.FacesContext, String)
* @since 1.2
*/
@Override
public UIViewRoot createView(FacesContext context, String viewId) {
return getWrapped().createView(context, viewId);
}
/**
*
* The default behavior of this method is to call
* {@link ViewHandler#renderView(jakarta.faces.context.FacesContext, jakarta.faces.component.UIViewRoot)} on the wrapped
* {@link ViewHandler} object.
*
*
* @see ViewHandler#renderView(jakarta.faces.context.FacesContext, jakarta.faces.component.UIViewRoot)
* @since 1.2
*/
@Override
public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException, FacesException {
getWrapped().renderView(context, viewToRender);
}
/**
*
*
* The default behavior of this method is to call
* {@link ViewHandler#calculateCharacterEncoding(jakarta.faces.context.FacesContext)} on the wrapped {@link ViewHandler}
* object.
*
*
* @see ViewHandler#calculateCharacterEncoding(jakarta.faces.context.FacesContext)
* @since 1.2
*/
@Override
public String calculateCharacterEncoding(FacesContext context) {
return getWrapped().calculateCharacterEncoding(context);
}
/**
*
*
* The default behavior of this method is to call
* {@link ViewHandler#calculateLocale(jakarta.faces.context.FacesContext)} on the wrapped {@link ViewHandler} object.
*
*
* @see ViewHandler#calculateLocale(jakarta.faces.context.FacesContext)
* @since 1.2
*/
@Override
public Locale calculateLocale(FacesContext context) {
return getWrapped().calculateLocale(context);
}
/**
*
*
* The default behavior of this method is to call
* {@link ViewHandler#deriveViewId(jakarta.faces.context.FacesContext, String)} on the wrapped {@link ViewHandler}
* object.
*
*
* @see ViewHandler#deriveViewId(jakarta.faces.context.FacesContext, String)
* @since 2.0
*/
@Override
public String deriveViewId(FacesContext context, String requestViewId) {
return getWrapped().deriveViewId(context, requestViewId);
}
/**
*
*
* The default behavior of this method is to call
* {@link ViewHandler#deriveLogicalViewId(jakarta.faces.context.FacesContext, String)} on the wrapped
* {@link ViewHandler} object.
*
*
* @see ViewHandler#deriveLogicalViewId(jakarta.faces.context.FacesContext, String)
* @since 2.1
*/
@Override
public String deriveLogicalViewId(FacesContext context, String requestViewId) {
return getWrapped().deriveLogicalViewId(context, requestViewId);
}
/**
*
* The default behavior of this method is to call
* {@link ViewHandler#calculateRenderKitId(jakarta.faces.context.FacesContext)} on the wrapped {@link ViewHandler}
* object.
*
*
* @see ViewHandler#calculateRenderKitId(jakarta.faces.context.FacesContext)
* @since 1.2
*/
@Override
public String calculateRenderKitId(FacesContext context) {
return getWrapped().calculateRenderKitId(context);
}
/**
*
* The default behavior of this method is to call
* {@link ViewHandler#getActionURL(jakarta.faces.context.FacesContext, String)} on the wrapped {@link ViewHandler}
* object.
*
*
* @see ViewHandler#getActionURL(jakarta.faces.context.FacesContext, String)
* @since 1.2
*/
@Override
public String getActionURL(FacesContext context, String viewId) {
return getWrapped().getActionURL(context, viewId);
}
/**
*
*
* The default behavior of this method is to call {@link ViewHandler#getProtectedViewsUnmodifiable} on the wrapped
* {@link ViewHandler} object.
*
*
* @see ViewHandler#getProtectedViewsUnmodifiable
* @since 2.2
*/
@Override
public Set getProtectedViewsUnmodifiable() {
return getWrapped().getProtectedViewsUnmodifiable();
}
/**
*
*
* The default behavior of this method is to call {@link ViewHandler#addProtectedView} on the wrapped
* {@link ViewHandler} object.
*
*
* @see ViewHandler#addProtectedView
* @since 2.2
*/
@Override
public void addProtectedView(String urlPattern) {
getWrapped().addProtectedView(urlPattern);
}
/**
*
*
* The default behavior of this method is to call {@link ViewHandler#removeProtectedView} on the wrapped
* {@link ViewHandler} object.
*
*
* @see ViewHandler#removeProtectedView
* @since 2.2
*/
@Override
public boolean removeProtectedView(String urlPattern) {
return getWrapped().removeProtectedView(urlPattern);
}
/**
*
* The default behavior of this method is to call
* {@link ViewHandler#getRedirectURL(jakarta.faces.context.FacesContext, String, java.util.Map, boolean)} on the wrapped
* {@link ViewHandler} object.
*
*
* @see ViewHandler#getRedirectURL(jakarta.faces.context.FacesContext, String, java.util.Map, boolean)
* @since 2.0
*/
@Override
public String getRedirectURL(FacesContext context, String viewId, Map> parameters, boolean includeViewParams) {
return getWrapped().getRedirectURL(context, viewId, parameters, includeViewParams);
}
/**
*
* The default behavior of this method is to call
* {@link ViewHandler#getBookmarkableURL(jakarta.faces.context.FacesContext, String, java.util.Map, boolean)} on the
* wrapped {@link ViewHandler} object.
*
*
* @see ViewHandler#getBookmarkableURL(jakarta.faces.context.FacesContext, String, java.util.Map, boolean)
* @since 2.0
*/
@Override
public String getBookmarkableURL(FacesContext context, String viewId, Map> parameters, boolean includeViewParams) {
return getWrapped().getBookmarkableURL(context, viewId, parameters, includeViewParams);
}
/**
*
* The default behavior of this method is to call
* {@link ViewHandler#getResourceURL(jakarta.faces.context.FacesContext, String)} on the wrapped {@link ViewHandler}
* object.
*
*
* @see ViewHandler#getResourceURL(jakarta.faces.context.FacesContext, String)
* @since 1.2
*/
@Override
public String getResourceURL(FacesContext context, String path) {
return getWrapped().getResourceURL(context, path);
}
/**
*
* The default behavior of this method is to call {@link ViewHandler#getWebsocketURL(FacesContext, String)} on the
* wrapped {@link ViewHandler} object.
*
*
* @see ViewHandler#getWebsocketURL(FacesContext, String)
* @since 2.3
*/
@Override
public String getWebsocketURL(FacesContext context, String channel) {
return getWrapped().getWebsocketURL(context, channel);
}
/**
*
* The default behavior of this method is to call {@link ViewHandler#getViewDeclarationLanguage} on the wrapped
* {@link ViewHandler} object.
*
*
* @since 2.0
*/
@Override
public ViewDeclarationLanguage getViewDeclarationLanguage(FacesContext context, String viewId) {
return getWrapped().getViewDeclarationLanguage(context, viewId);
}
/**
*
* The default behavior of this method is to call {@link ViewHandler#getViews(FacesContext, String, ViewVisitOption...)}
* on the wrapped {@link ViewHandler} object.
*
*
* @since 2.3
*/
@Override
public Stream getViews(FacesContext context, String path, ViewVisitOption... options) {
return getWrapped().getViews(context, path, options);
}
/**
*
* The default behavior of this method is to call
* {@link ViewHandler#getViews(FacesContext, String, int, ViewVisitOption...)} on the wrapped {@link ViewHandler}
* object.
*
*
* @since 2.3
*/
@Override
public Stream getViews(FacesContext context, String path, int maxDepth, ViewVisitOption... options) {
return getWrapped().getViews(context, path, maxDepth, options);
}
/**
*
* The default behavior of this method is to call {@link ViewHandler#writeState(jakarta.faces.context.FacesContext)} on
* the wrapped {@link ViewHandler} object.
*
*
* @see ViewHandler#writeState(jakarta.faces.context.FacesContext)
* @since 1.2
*/
@Override
public void writeState(FacesContext context) throws IOException {
getWrapped().writeState(context);
}
// ------------------------------------------------------------- Deprecated methods
/**
* @deprecated Use the other constructor taking the implementation being wrapped.
*/
@Deprecated
public ViewHandlerWrapper() {
}
}