TagExtraInfo (Java EE 5)

Java EE API


javax.servlet.jsp.tagext Class TagExtraInfo

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagExtraInfo

public abstract class TagExtraInfo
extends Object


标记库作者提供的可选类,用于描述 TLD 中没有描述的其他转换期间信息。标记库描述符文件 (TLD) 中提到过 TagExtraInfo 类。

此类可用于:

  • 指示标记定义了脚本变量
  • 执行标记属性的转换期间验证。

JSP 转换器负责使调用 getTagInfo() 返回的初始值对应于将被转换的标记的 TagInfo 对象。如果对 setTagInfo() 进行显式调用,则传递的对象将在 getTagInfo() 的后续调用中返回。

影响 getTagInfo() 返回的值的唯一方式是通过 setTagInfo() 调用,因此将通过 JSP 转换器使用对应于将被转换的标记的 TagInfo 对象调用 TagExtraInfo.setTagInfo()。该调用应该发生在任何 validate() 调用和任何 getVariableInfo() 调用之前。

注:如果 TLD 中的标记定义如下:一个或多个变量子元素拥有的关联 TagExtraInfo 实现所返回的 VariableInfo 调用 getVariableInfo() 将返回一个或多个元素,那么这是一个(转换期间)错误。

英文文档:

Optional class provided by the tag library author to describe additional translation-time information not described in the TLD. The TagExtraInfo class is mentioned in the Tag Library Descriptor file (TLD).

This class can be used:

  • to indicate that the tag defines scripting variables
  • to perform translation-time validation of the tag attributes.

It is the responsibility of the JSP translator that the initial value to be returned by calls to getTagInfo() corresponds to a TagInfo object for the tag being translated. If an explicit call to setTagInfo() is done, then the object passed will be returned in subsequent calls to getTagInfo().

The only way to affect the value returned by getTagInfo() is through a setTagInfo() call, and thus, TagExtraInfo.setTagInfo() is to be called by the JSP translator, with a TagInfo object that corresponds to the tag being translated. The call should happen before any invocation on validate() and before any invocation on getVariableInfo().

NOTE: It is a (translation time) error for a tag definition in a TLD with one or more variable subelements to have an associated TagExtraInfo implementation that returns a VariableInfo array with one or more elements from a call to getVariableInfo().


Constructor Summary
 
Method Summary
 TagInfo
 VariableInfo[]
 boolean
 void
 ValidationMessage[]
 
Methods inherited from class java.lang.Object
 

Constructor Detail

public TagExtraInfo()
唯一的构造方法。(由子类构造方法调用,通常是隐式的)。
英文文档:

TagExtraInfo

public TagExtraInfo()
Sole constructor. (For invocation by subclass constructors, typically implicit.)

Method Detail

public VariableInfo[] getVariableInfo(TagData data)
与此 TagExtraInfo 实例关联的由标记定义的脚本变量的信息。请求期间属性通过 TagData 参数的值指定。
data TagData 实例。
return VariableInfo 数据数组,如果没有要定义的脚本变量,则返回 null 或长度为 0 的数组。
英文文档:

getVariableInfo

public VariableInfo[] getVariableInfo(TagData data)
information on scripting variables defined by the tag associated with this TagExtraInfo instance. Request-time attributes are indicated as such in the TagData parameter.

Parameters:
data - The TagData instance.
Returns:
An array of VariableInfo data, or null or a zero length array if no scripting variables are to be defined.

public boolean isValid(TagData data)
属性的转换期间验证。请求期间属性通过 TagData 参数的值指定。注意,执行验证的首选方式是使用 validate() 方法,因为它可以返回更详细的信息。
data TagData 实例。
return 此标记实例是否有效。
See also validate
英文文档:

isValid

public boolean isValid(TagData data)
Translation-time validation of the attributes. Request-time attributes are indicated as such in the TagData parameter. Note that the preferred way to do validation is with the validate() method, since it can return more detailed information.

Parameters:
data - The TagData instance.
Returns:
Whether this tag instance is valid.
See Also:
validate(javax.servlet.jsp.tagext.TagData)

public ValidationMessage[] validate(TagData data)
属性的转换期间验证。请求期间属性通过 TagData 参数的值指定。因为可能提供更高质量的验证消息,所以这是执行验证的首选方式(尽管 isValid() 仍然有效)。

JSP 2.0 和更高版本的容器将调用 validate(),而不是 isValid()。此方法的默认实现是调用 isValid()。如果 isValid() 返回 false,则返回指示 isValid() 返回 false 的一般 ValidationMessage[]。

data TagData 实例。
return 一个 null 对象,如果没有错误,则返回长度为 0 的数组,否则返回 ValidationMessage 数组。
since2.0
英文文档:

validate

public ValidationMessage[] validate(TagData data)
Translation-time validation of the attributes. Request-time attributes are indicated as such in the TagData parameter. Because of the higher quality validation messages possible, this is the preferred way to do validation (although isValid() still works).

JSP 2.0 and higher containers call validate() instead of isValid(). The default implementation of this method is to call isValid(). If isValid() returns false, a generic ValidationMessage[] is returned indicating isValid() returned false.

Parameters:
data - The TagData instance.
Returns:
A null object, or zero length array if no errors, an array of ValidationMessages otherwise.
Since:
JSP 2.0

final public void setTagInfo(TagInfo tagInfo)
设置此类的 TagInfo。
tagInfo 此实例要扩展的 TagInfo
英文文档:

setTagInfo

public final void setTagInfo(TagInfo tagInfo)
Set the TagInfo for this class.

Parameters:
tagInfo - The TagInfo this instance is extending

final public TagInfo getTagInfo()
获取此类的 TagInfo。
return 此实例要扩展的 taginfo 实例
英文文档:

getTagInfo

public final TagInfo getTagInfo()
Get the TagInfo for this class.

Returns:
the taginfo instance this instance is extending


Submit a bug or feature

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

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

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