TagSupport (Java EE 5)

Java EE API


javax.servlet.jsp.tagext Class TagSupport

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
All Implemented Interfaces:
Serializable, IterationTag, JspTag, Tag
Direct Known Subclasses:
AttributeTag, BodyTagSupport, ConverterELTag, ConverterTag, FacetTag, ValidatorELTag, ValidatorTag

public class TagSupport
extends Object
implements IterationTag, Serializable

Implements: IterationTag, java.io.Serializable

用来定义实现 Tag 的新标记处理程序的基类。

TagSupport 类是一个实用工具类,旨在用作新标记处理程序的基类。TagSupport 类实现 Tag 和 IterationTag 接口,并添加了其他便捷方法,包括用于 Tag 中属性的 getter 方法。TagSupport 有一个静态方法,包含该方法是为了促进各协作标记之间的协调。

许多标记处理程序将扩展 TagSupport,并且仅重新定义少数几个方法。

英文文档:

A base class for defining new tag handlers implementing Tag.

The TagSupport class is a utility class intended to be used as the base class for new tag handlers. The TagSupport class implements the Tag and IterationTag interfaces and adds additional convenience methods including getter methods for the properties in Tag. TagSupport has one static method that is included to facilitate coordination among cooperating tags.

Many tag handlers will extend TagSupport and only redefine a few methods.

See Also:
Serialized Form

Field Summary
protected  String
protected  PageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
 
Constructor Summary
 
Method Summary
 int
 int
 int
static Tag
 String
 Tag
 Object
 Enumeration<String>
 void
 void
 void
 void
 void
 void
 
Methods inherited from class java.lang.Object
 

Field Detail

英文文档:

id

protected String id
The value of the id attribute of this tag; or null.


英文文档:

pageContext

protected PageContext pageContext
The PageContext.

Constructor Detail

public TagSupport()
默认构造方法,所有子类只需定义一个具有相同签名的公共构造方法并调用该超类构造方法。 此构造方法通过 JSP 转换器生成的代码调用。
英文文档:

TagSupport

public TagSupport()
Default constructor, all subclasses are required to define only a public constructor with the same signature, and to call the superclass constructor. This constructor is called by the code generated by the JSP translator.

Method Detail

final public static Tag findAncestorWithClass(Tag from, Class<T> klass)
查找最接近给定实例的给定类类型的实例。此方法使用来自 Tag 接口的 getParent 方法。此方法用于协调各协作标记。

规范的当前版本仅提供一种正式方法指示标记处理程序的 observable 类型:其标记处理程序实现类,在标记元素的标记类子元素中描述。这可以通过一种非正式的方法扩展,即允许标记库作者在描述子元素中指示 observable 类型。该类型应该是标记处理程序实现类的子类型或者是 void 类型。支持特定标记库(比如 JSP 标准标记库)的专门化容器可以利用这一附加限制。

当标记库作者提供有关标记处理程序 observable 类型的信息时,客户端编程代码应该遵守该限制。具体地说,传递给 findAncestorWithClass 的类应该是 observable 类型的子类型。

from 开始查找实例的位置。
klass 将匹配的 Tag 或接口的子类
return 实现该接口的最接近的祖先,或者指定类的实例

英文文档:

findAncestorWithClass

public static final Tag findAncestorWithClass(Tag from,
                                              Class klass)
Find the instance of a given class type that is closest to a given instance. This method uses the getParent method from the Tag interface. This method is used for coordination among cooperating tags.

The current version of the specification only provides one formal way of indicating the observable type of a tag handler: its tag handler implementation class, described in the tag-class subelement of the tag element. This is extended in an informal manner by allowing the tag library author to indicate in the description subelement an observable type. The type should be a subtype of the tag handler implementation class or void. This addititional constraint can be exploited by a specialized container that knows about that specific tag library, as in the case of the JSP standard tag library.

When a tag library author provides information on the observable type of a tag handler, client programmatic code should adhere to that constraint. Specifically, the Class passed to findAncestorWithClass should be a subtype of the observable type.

Parameters:
from - The instance from where to start looking.
klass - The subclass of Tag or interface to be matched
Returns:
the nearest ancestor that implements the interface or is an instance of the class specified

public int doStartTag() throws JspException
开始标记的默认处理,返回 SKIP_BODY。
returnSKIP_BODY
ThrowsJspException: 如果处理此标记时发生错误
See also doStartTag()
英文文档:

doStartTag

public int doStartTag()
               throws JspException
Default processing of the start tag, returning SKIP_BODY.

Specified by:
doStartTag in interface Tag
Returns:
SKIP_BODY
Throws:
JspException - if an error occurs while processing this tag
See Also:
Tag.doStartTag()

public int doEndTag() throws JspException
结束标记的默认处理,返回 EVAL_PAGE。
returnEVAL_PAGE
ThrowsJspException: 如果处理此标记时发生错误
See also doEndTag()
英文文档:

doEndTag

public int doEndTag()
             throws JspException
Default processing of the end tag returning EVAL_PAGE.

Specified by:
doEndTag in interface Tag
Returns:
EVAL_PAGE
Throws:
JspException - if an error occurs while processing this tag
See Also:
Tag.doEndTag()

public int doAfterBody() throws JspException
正文的默认处理。
returnSKIP_BODY
ThrowsJspException: 如果处理此标记时发生错误
See also doAfterBody()
英文文档:

doAfterBody

public int doAfterBody()
                throws JspException
Default processing for a body.

Specified by:
doAfterBody in interface IterationTag
Returns:
SKIP_BODY
Throws:
JspException - if an error occurs while processing this tag
See Also:
IterationTag.doAfterBody()

public void release()
释放状态。
See also release()
英文文档:

release

public void release()
Release state.

Specified by:
release in interface Tag
See Also:
Tag.release()

public void setParent(Tag t)
设置此标记的嵌套标记。
t 父 Tag。
See also setParent(Tag)
英文文档:

setParent

public void setParent(Tag t)
Set the nesting tag of this tag.

Specified by:
setParent in interface Tag
Parameters:
t - The parent Tag.
See Also:
Tag.setParent(Tag)

public Tag getParent()
封闭此标记实例的最接近的标记实例。
return 父标记实例或 null
See also getParent()
英文文档:

getParent

public Tag getParent()
The Tag instance most closely enclosing this tag instance.

Specified by:
getParent in interface Tag
Returns:
the parent tag instance or null
See Also:
Tag.getParent()

public void setId(String id)
设置此标记的 id 属性。
id id 的 String。
英文文档:

setId

public void setId(String id)
Set the id attribute for this tag.

Parameters:
id - The String for the id.

public String getId()
此标记的 id 属性值;或者为 null。
return id 属性的值,或者返回 null
英文文档:

getId

public String getId()
The value of the id attribute of this tag; or null.

Returns:
the value of the id attribute, or null

public void setPageContext(PageContext pageContext)
设置页面上下文。
pageContext PageContext。
See also setPageContext
英文文档:

setPageContext

public void setPageContext(PageContext pageContext)
Set the page context.

Specified by:
setPageContext in interface Tag
Parameters:
pageContext - The PageContext.
See Also:
Tag.setPageContext(javax.servlet.jsp.PageContext)

public void setValue(String k, Object o)
将值与 String 键相关联。
k 键 String。
o 要关联的值。
英文文档:

setValue

public void setValue(String k,
                     Object o)
Associate a value with a String key.

Parameters:
k - The key String.
o - The value to associate.

public Object getValue(String k)
获取与某个键关联的值。
k 字符串键。
return 与此键关联的值,或者返回 null。
英文文档:

getValue

public Object getValue(String k)
Get a the value associated with a key.

Parameters:
k - The string key.
Returns:
The value associated with the key, or null.

public void removeValue(String k)
移除与某个键关联的值。
k 字符串键。
英文文档:

removeValue

public void removeValue(String k)
Remove a value associated with a key.

Parameters:
k - The string key.

public java.util.Enumeration<E> getValues()
枚举此标记处理程序保存的值对应的键。
return 设置的值对应的所有键的枚举,如果未设置任何值,则返回 null 或一个空 Enumeration。
英文文档:

getValues

public Enumeration<String> getValues()
Enumerate the keys for the values kept by this tag handler.

Returns:
An enumeration of all the keys for the values set, or null or an empty Enumeration if no values have been set.


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!