|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.servlet.jsp.tagext Class TagAdapter
java.lang.Object javax.servlet.jsp.tagext.TagAdapter
包装任何 SimpleTag,并使用 Tag 接口公开它。此类用于支持经典标记处理程序与 SimpleTag 处理程序之间的协作。
因为 SimpleTag 没有扩展 Tag,并且因为 Tag.setParent() 只接受 Tag 实例,所以经典标记处理程序(实现 Tag 的经典标记处理程序)无法使 SimpleTag 成为其父标记。为了对此进行补救,可创建 TagAdapter 来包装 SimpleTag 父标记,并将适配器传递给 setParent()。经典标记处理程序可以调用 getAdaptee() 来获取已封装的 SimpleTag 实例。
since | 2.0 |
Wraps any SimpleTag and exposes it using a Tag interface. This is used to allow collaboration between classic Tag handlers and SimpleTag handlers.
Because SimpleTag does not extend Tag, and because Tag.setParent() only accepts a Tag instance, a classic tag handler (one that implements Tag) cannot have a SimpleTag as its parent. To remedy this, a TagAdapter is created to wrap the SimpleTag parent, and the adapter is passed to setParent() instead. A classic Tag Handler can call getAdaptee() to retrieve the encapsulated SimpleTag instance.
- Since:
- JSP 2.0
Field Summary |
---|
Fields inherited from interface javax.servlet.jsp.tagext.Tag |
---|
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE |
Constructor Summary | |
---|---|
TagAdapter(SimpleTag adaptee)
Creates a new TagAdapter that wraps the given SimpleTag and returns the parent tag when getParent() is called. |
Method Summary | |
---|---|
int |
doEndTag()
Must not be called. |
int |
doStartTag()
Must not be called. |
JspTag |
getAdaptee()
Gets the tag that is being adapted to the Tag interface. |
Tag |
getParent()
Returns the parent of this tag, which is always getAdaptee().getParent(). |
void |
release()
Must not be called. |
void |
setPageContext(PageContext pc)
Must not be called. |
void |
setParent(Tag parentTag)
Must not be called. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public
TagAdapter(SimpleTag adaptee)
创建包装给定 SimpleTag 的新 TagAdapter,并在调用 getParent() 时返回父标记。
adaptee | 将被适配为 Tag 的 SimpleTag。 |
TagAdapter
public TagAdapter(SimpleTag adaptee)
- Creates a new TagAdapter that wraps the given SimpleTag and
returns the parent tag when getParent() is called.
- Parameters:
adaptee
- The SimpleTag being adapted as a Tag.
Method Detail |
---|
public void
setPageContext(PageContext pc)
不得调用。
pc | 忽略。 |
Throws | UnsupportedOperationException: 不得调用 |
setPageContext
public void setPageContext(PageContext pc)
- Must not be called.
- Specified by:
setPageContext
in interfaceTag
- Parameters:
pc
- ignored.- Throws:
UnsupportedOperationException
- Must not be called
public void
setParent(Tag parentTag)
不得调用。此标记的父标记始终是 getAdaptee().getParent()。
parentTag | 忽略。 |
Throws | UnsupportedOperationException: 不得调用。 |
setParent
public void setParent(Tag parentTag)
- Must not be called. The parent of this tag is always
getAdaptee().getParent().
- Parameters:
parentTag
- ignored.- Throws:
UnsupportedOperationException
- Must not be called.
public Tag
getParent()
返回此标记的父标记,该父标记始终是 getAdaptee().getParent()。
此父标记可能是封闭 Tag(如果 getAdaptee().getParent() 实现了 Tag),也可能是封闭 Tag 的适配器(如果 getAdaptee().getParent() 没有实现 Tag)。
return | 将被适配的标记的父标记。 |
getParent
public Tag getParent()
- Returns the parent of this tag, which is always
getAdaptee().getParent().
This will either be the enclosing Tag (if getAdaptee().getParent()
implements Tag), or an adapter to the enclosing Tag (if
getAdaptee().getParent() does not implement Tag).
- Returns:
- The parent of the tag being adapted.
- See Also:
TagSupport.findAncestorWithClass(javax.servlet.jsp.tagext.Tag, java.lang.Class)
public JspTag
getAdaptee()
获取将被适配到 Tag 接口的标记。在 JSP 2.0 中,此标记应该是 SimpleTag 实例,但为以后规范版本中的其他种类的标记保留了空间。
return | 将被适配的标记 |
getAdaptee
public JspTag getAdaptee()
- Gets the tag that is being adapted to the Tag interface.
This should be an instance of SimpleTag in JSP 2.0, but room
is left for other kinds of tags in future spec versions.
- Returns:
- the tag that is being adapted
public int
doStartTag() throws JspException
不得调用。
return | 总是抛出 UnsupportedOperationException |
Throws | UnsupportedOperationException: 不得调用 |
Throws | JspException: 不会抛出 |
doStartTag
public int doStartTag() throws JspException
- Must not be called.
- Specified by:
doStartTag
in interfaceTag
- Returns:
- always throws UnsupportedOperationException
- Throws:
UnsupportedOperationException
- Must not be calledJspException
- never thrown- See Also:
BodyTag
public int
doEndTag() throws JspException
不得调用。
return | 总是抛出 UnsupportedOperationException |
Throws | UnsupportedOperationException: 不得调用 |
Throws | JspException: 不会抛出 |
doEndTag
public int doEndTag() throws JspException
- Must not be called.
- Returns:
- always throws UnsupportedOperationException
- Throws:
UnsupportedOperationException
- Must not be calledJspException
- never thrown
public void
release()
不得调用。
Throws | UnsupportedOperationException: 不得调用 |
release
public void release()
- Must not be called.
- Throws:
UnsupportedOperationException
- Must not be called
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!