📄 extendedfaceletviewhandler.java
字号:
/* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package de.mindmatters.faces.application;import java.io.IOException;import javax.faces.application.ViewHandler;import javax.faces.component.UIViewRoot;import javax.faces.context.FacesContext;import com.sun.facelets.FaceletViewHandler;/** * Extends {@link FaceletViewHandler} to implement * {@link ViewBuilder#buildView(FacesContext, String)}. * * <p> * <strong>Should never used directly within a faces-config file. Will be * instantiated by the {@link FaceletViewBuilder} class via reflection.</strong> * </p> * * @author Andreas Kuhrwahl */public class ExtendedFaceletViewHandler extends FaceletViewHandler { /** Already Initialized? */ private Object isInitialized; /** * Default constructor. <strong>Must</strong> be invoked by subclasses. * * @param viewHandler * the original ViewHandler of the underlying JSF implementation. */ public ExtendedFaceletViewHandler(final ViewHandler viewHandler) { super(viewHandler); } /** * {@inheritDoc} */ protected void initialize(final FacesContext context) { synchronized (this) { if (this.isInitialized == null) { this.isInitialized = new Object(); super.initialize(context); } } } /** * {@inheritDoc} */ protected final String getRenderedViewId(final FacesContext context, final String actionId) { return actionId; } /** * Builds the view. * * @param context * {@link FacesContext} for the current request * @param viewId * the view identifier for the current request * @return the created {@link UIViewRoot} * @throws javax.faces.FacesException * if a servlet error occurs * @throws IOException * if an input/output error occurs */ public final UIViewRoot buildView(final FacesContext context, final String viewId) throws IOException { if (this.isInitialized == null) { this.initialize(context); } UIViewRoot viewRoot = createView(context, viewId); context.setViewRoot(viewRoot); super.buildView(context, viewRoot); return viewRoot; } /** * {@inheritDoc} */ protected final void buildView(final FacesContext context, final UIViewRoot viewToRender) throws IOException { if (viewToRender.getChildren().isEmpty()) { super.buildView(context, viewToRender); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -