📄 inserttag.java
字号:
/*
* $Header: /sfroot/cvs/esimple/src/core/com/esimple/framework/web/taglib/tiles/InsertTag.java,v 1.1.1.1 2004/09/08 06:38:26 lava Exp $
* $Revision: 1.1.1.1 $
* $Date: 2004/09/08 06:38:26 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Struts", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package com.esimple.framework.web.taglib.tiles;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;
import java.util.StringTokenizer;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.Globals;
import com.esimple.framework.web.taglib.tiles.util.TagUtils;
import org.apache.struts.tiles.AttributeDefinition;
import org.apache.struts.tiles.ComponentContext;
import org.apache.struts.tiles.ComponentDefinition;
import org.apache.struts.tiles.Controller;
import org.apache.struts.tiles.DefinitionAttribute;
import org.apache.struts.tiles.DefinitionNameAttribute;
import org.apache.struts.tiles.DefinitionsFactoryException;
import org.apache.struts.tiles.DirectStringAttribute;
import org.apache.struts.tiles.FactoryNotFoundException;
import org.apache.struts.tiles.NoSuchDefinitionException;
import org.apache.struts.tiles.TilesUtil;
/**
* This is the tag handler for <tiles:insert>, which includes
* a template. The tag's body content consists of <tiles:put>
* tags, which are accessed by <tiles:get> in the template.
*
* @author David Geary
* @author Cedric Dumoulin
* @version $Revision: 1.1.1.1 $ $Date: 2004/09/08 06:38:26 $
*/
public class InsertTag
extends DefinitionTagSupport
implements PutTagParent, ComponentConstants, PutListTagParent {
/** Commons Logging instance. */
protected static Log log = LogFactory.getLog(InsertTag.class);
/* JSP Tag attributes */
/** Flush attribute value */
protected boolean flush = true;
/** Name to insert */
protected String name = null;
/** Name of attribute from which to read page name to include */
protected String attribute = null;
/** Name of bean used as entity to include */
protected String beanName = null;
/** Name of bean property, if any */
protected String beanProperty = null;
/** Scope of bean, if any */
protected String beanScope = null;
/**
* Are errors ignored. This is the property for attribute 'ignore'.
* Default value is false, which throw an exception.
* Only 'attribute not found' errors are ignored.
*/
protected boolean isErrorIgnored = false;
/** Name of component instance to include */
protected String definitionName = null;
/* Internal properties */
/**
* Does the end tag need to be processed.
* Default value is true. Boolean set in case of ignored errors.
*/
protected boolean processEndTag = true;
/** Current component context */
protected ComponentContext cachedCurrentContext;
/** Finale handler of tag methods */
protected TagHandler tagHandler = null;
/** Trick to allows inner classes to access pageContext */
protected PageContext pageContext = null;
/**
* Reset member values for reuse. This method calls super.release(),
* which invokes TagSupport.release(), which typically does nothing.
*/
public void release() {
super.release();
attribute = null;
beanName = null;
beanProperty = null;
beanScope = null;
definitionName = null;
flush = true;
name = null;
page = null;
role = null;
isErrorIgnored = false;
releaseInternal();
}
/**
* Reset internal member values for reuse.
*/
protected void releaseInternal() {
cachedCurrentContext = null;
processEndTag = true;
// pageContext = null; // orion doesn't set it between two tags
tagHandler = null;
}
/**
* Set the current page context.
* Called by the page implementation prior to doStartTag().
* <p>
* Needed to allow inner classes to access pageContext.
*/
public void setPageContext(PageContext pc) {
this.pageContext = pc;
super.setPageContext(pc);
}
/**
* Get the pageContext property.
*/
public PageContext getPageContext() {
return pageContext;
}
/**
* Set name.
*/
public void setName(String value) {
this.name = value;
}
/**
* Get name.
*/
public String getName() {
return name;
}
/**
* Set component.
*/
public void setComponent(String name) {
this.page = name;
}
/**
* Set instance.
* @deprecated Use setDefinition() instead.
*/
public void setInstance(String name) {
this.definitionName = name;
}
/**
* Set definition.
*/
public void setDefinition(String name) {
this.definitionName = name;
}
/**
* Get definition name.
*/
public String getDefinitionName() {
return definitionName;
}
/**
* Set attribute.
*/
public void setAttribute(String value) {
this.attribute = value;
}
/**
* Set bean name.
*/
public void setBeanName(String value) {
this.beanName = value;
}
/**
* Get bean name.
*/
public String getBeanName() {
return beanName;
}
/**
* Set bean property.
*/
public void setBeanProperty(String value) {
this.beanProperty = value;
}
/**
* Get bean property.
*/
public String getBeanProperty() {
return beanProperty;
}
/**
* Set bean scope.
*/
public void setBeanScope(String value) {
this.beanScope = value;
}
/**
* Get bean scope.
*/
public String getBeanScope() {
return beanScope;
}
/**
* Set flush.
*/
public void setFlush(boolean flush) {
this.flush = flush;
}
/**
* Get flush.
*/
public boolean getFlush() {
return flush;
}
/**
* Set flush.
* Method added for compatibility with JSP1.1
*/
public void setFlush(String flush) {
this.flush = (Boolean.valueOf(flush).booleanValue());
}
/**
* Set ignore.
*/
public void setIgnore(boolean ignore) {
this.isErrorIgnored = ignore;
}
/**
* Get ignore.
*/
public boolean getIgnore() {
return isErrorIgnored;
}
/////////////////////////////////////////////////////////////////////////
/**
* Add a body attribute.
* Erase any attribute with same name previously set.
*/
public void putAttribute(String name, Object value) {
tagHandler.putAttribute(name, value);
}
/**
* Process nested ≶put> tag.
* Method calls by nested ≶put> tags.
* Nested list is added to current list.
* If role is defined, it is checked immediately.
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -