本文整理了Java中javax.servlet.jsp.tagext.Tag.getParent()
方法的一些代码示例,展示了Tag.getParent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tag.getParent()
方法的具体详情如下:
包路径:javax.servlet.jsp.tagext.Tag
类名称:Tag
方法名:getParent
[英]Get the parent (closest enclosing tag handler) for this tag handler.
The getParent() method can be used to navigate the nested tag handler structure at runtime for cooperation among custom actions; for example, the findAncestorWithClass() method in TagSupport provides a convenient way of doing this.
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.
[中]获取此标记处理程序的父级(最近的封闭标记处理程序)。
getParent()方法可用于在运行时导航嵌套的标记处理程序结构,以便在自定义操作之间进行协作;例如,TagSupport中的findAncestorWithClass()方法提供了一种方便的方法。
规范的当前版本只提供了一种表示标记处理程序的可观察类型的正式方法:其标记处理程序实现类,在标记元素的标记类子元素中描述。通过允许标记库作者在描述子元素中指示一个可观察的类型,可以以非正式的方式对其进行扩展。类型应该是标记处理程序实现类的子类型或void。这个附加约束可以被一个专门的容器利用,这个容器知道特定的标记库,比如JSP标准标记库。
代码示例来源:origin: spring-projects/spring-framework
/**
* Determine whether the supplied {@link Tag} has any ancestor tag
* of the supplied type.
* @param tag the tag whose ancestors are to be checked
* @param ancestorTagClass the ancestor {@link Class} being searched for
* @return {@code true} if the supplied {@link Tag} has any ancestor tag
* of the supplied type
* @throws IllegalArgumentException if either of the supplied arguments is {@code null};
* or if the supplied {@code ancestorTagClass} is not type-assignable to
* the {@link Tag} class
*/
public static boolean hasAncestorOfType(Tag tag, Class<?> ancestorTagClass) {
Assert.notNull(tag, "Tag cannot be null");
Assert.notNull(ancestorTagClass, "Ancestor tag class cannot be null");
if (!Tag.class.isAssignableFrom(ancestorTagClass)) {
throw new IllegalArgumentException(
"Class '" + ancestorTagClass.getName() + "' is not a valid Tag type");
}
Tag ancestor = tag.getParent();
while (ancestor != null) {
if (ancestorTagClass.isAssignableFrom(ancestor.getClass())) {
return true;
}
ancestor = ancestor.getParent();
}
return false;
}
代码示例来源:origin: org.springframework/spring-web
/**
* Determine whether the supplied {@link Tag} has any ancestor tag
* of the supplied type.
* @param tag the tag whose ancestors are to be checked
* @param ancestorTagClass the ancestor {@link Class} being searched for
* @return {@code true} if the supplied {@link Tag} has any ancestor tag
* of the supplied type
* @throws IllegalArgumentException if either of the supplied arguments is {@code null};
* or if the supplied {@code ancestorTagClass} is not type-assignable to
* the {@link Tag} class
*/
public static boolean hasAncestorOfType(Tag tag, Class<?> ancestorTagClass) {
Assert.notNull(tag, "Tag cannot be null");
Assert.notNull(ancestorTagClass, "Ancestor tag class cannot be null");
if (!Tag.class.isAssignableFrom(ancestorTagClass)) {
throw new IllegalArgumentException(
"Class '" + ancestorTagClass.getName() + "' is not a valid Tag type");
}
Tag ancestor = tag.getParent();
while (ancestor != null) {
if (ancestorTagClass.isAssignableFrom(ancestor.getClass())) {
return true;
}
ancestor = ancestor.getParent();
}
return false;
}
代码示例来源:origin: javax.servlet.jsp/jsp-api
Tag tag = from.getParent();
代码示例来源:origin: javax.servlet.jsp/jsp-api
parent = ((Tag)from).getParent();
代码示例来源:origin: javax.servlet.jsp/javax.servlet.jsp-api
Tag tag = from.getParent();
代码示例来源:origin: javax.servlet.jsp/javax.servlet.jsp-api
parent = ((Tag)from).getParent();
代码示例来源:origin: com.mockrunner/mockrunner-tag
/**
* Delegates to wrapped tag.
*/
public Tag getParent()
{
return tag.getParent();
}
代码示例来源:origin: com.mockrunner/mockrunner-jdk1.3-j2ee1.3
/**
* Delegates to wrapped tag.
*/
public Tag getParent()
{
return tag.getParent();
}
代码示例来源:origin: com.mockrunner/mockrunner-jdk1.4-j2ee1.3
/**
* Delegates to wrapped tag.
*/
public Tag getParent()
{
return tag.getParent();
}
代码示例来源:origin: webwork/webwork-jira
public static Tag findTagWithClass(Tag current, Class cl)
{
Tag p = current.getParent();
while(p != null)
{
if(cl.isAssignableFrom(p.getClass()))
return p;
p = p.getParent();
}
return null;
}
}
代码示例来源:origin: org.codehaus.waffle/waffle-taglib
/**
* Searchs a parent tag that implements the selected type.
*
* @param <T> the type to search
* @param type the class type to search
* @return the tag found or null if not found
*/
@SuppressWarnings("unchecked")
protected <T> T findAncestor(Class<T> type) {
Tag current = parent;
while (current != null && !type.isAssignableFrom(current.getClass())) {
current = current.getParent();
}
return (T) current;
}
代码示例来源:origin: com.caucho/javaee-16
/**
* Finds an ancestor of a tag matching the class. The search is strict,
* i.e. only parents will be searched, not the tag itself.
*
* @param tag child tag to start searching.
* @param cl the class that the tag should implement.
*
* @return the matching tag or null.
*/
public static final Tag findAncestorWithClass(Tag tag, Class cl)
{
if (tag == null || cl == null)
return null;
tag = tag.getParent();
for (; tag != null; tag = tag.getParent()) {
if (cl.isAssignableFrom(tag.getClass()))
return tag;
}
return tag;
}
代码示例来源:origin: perfectsense/dari
private com.psddev.dari.util.FormTag getParentFormTag() {
Tag parent = getParent();
while (parent != null) {
if (parent instanceof com.psddev.dari.util.FormTag) {
return (com.psddev.dari.util.FormTag) parent;
}
parent = parent.getParent();
}
return null;
}
代码示例来源:origin: net.sourceforge.stripes/stripes
/**
* Figures out what to use as the value, and then finds the parent link and adds
* the parameter.
* @return EVAL_PAGE in all cases.
*/
public int doEndTag() throws JspException {
Object valueToSet = value;
// First figure out what value to send to the parent link tag
if (value == null) {
if (this.bodyContent == null) {
valueToSet = "";
}
else {
valueToSet = this.bodyContent.getString();
}
}
// Find the parent link tag
Tag parameterizable = this.parentTag;
while (parameterizable != null && !(parameterizable instanceof ParameterizableTag)) {
parameterizable = parameterizable.getParent();
}
((ParameterizableTag) parameterizable).addParameter(name, valueToSet);
return EVAL_PAGE;
}
代码示例来源:origin: StripesFramework/stripes
/**
* Figures out what to use as the value, and then finds the parent link and
* adds the parameter.
*
* @return EVAL_PAGE in all cases.
* @throws javax.servlet.jsp.JspException
*/
public int doEndTag() throws JspException {
Object valueToSet = value;
// First figure out what value to send to the parent link tag
if (value == null) {
if (this.bodyContent == null) {
valueToSet = "";
} else {
valueToSet = this.bodyContent.getString();
}
}
// Find the parent link tag
Tag parameterizable = this.parentTag;
while (parameterizable != null && !(parameterizable instanceof ParameterizableTag)) {
parameterizable = parameterizable.getParent();
}
((ParameterizableTag) parameterizable).addParameter(name, valueToSet);
return EVAL_PAGE;
}
代码示例来源:origin: com.caucho/resin
/**
* Process the tag.
*/
public int doStartTag()
throws JspException
{
if (! _hasValueSet)
return EVAL_BODY_BUFFERED;
PageContextImpl pageContext = (PageContextImpl) this.pageContext;
Object value = _value;
Tag parent = getParent();
for (;
parent != null && ! (parent instanceof SQLExecutionTag);
parent = parent.getParent()) {
}
if (parent == null)
throw new JspException(L.l("sql:param requires sql:query parent."));
SQLExecutionTag tag = (SQLExecutionTag) parent;
tag.addSQLParameter(value);
return SKIP_BODY;
}
代码示例来源:origin: com.bbossgroups.pdp/pdp-system
/**
* Record this action with our surrounding ActionsTag instance.
*
* @exception JspException if a processing error occurs
*/
public int doEndTag() throws JspException {
// Find our parent TableTag instance
Tag parent = getParent();
while ((parent != null) && !(parent instanceof TableTag)) {
parent = parent.getParent();
}
if (parent == null) {
throw new JspException("Must be nested in a TableTag instance");
}
TableTag table = (TableTag) parent;
// Register the information for the row represented by
// this row
HttpServletResponse response =
(HttpServletResponse) pageContext.getResponse();
table.addRow(header, label, data, labelStyle, dataStyle, styleId);
return (EVAL_PAGE);
}
代码示例来源:origin: com.caucho/resin
for (;
parent != null && ! (parent instanceof SQLExecutionTag);
parent = parent.getParent()) {
代码示例来源:origin: com.caucho/resin
/**
* Process the tag.
*/
public int doStartTag()
throws JspException
{
if (_name == null)
return SKIP_BODY;
if (_value == null)
return EVAL_BODY_BUFFERED;
Tag parent = getParent();
for (; parent != null; parent = parent.getParent()) {
if (parent instanceof NameValueTag) {
NameValueTag tag = (NameValueTag) parent;
if (_value == null)
tag.addParam(_name, "");
else
tag.addParam(_name, _value);
return SKIP_BODY;
}
}
throw new JspException(L.l("c:param requires c:url or c:import parent."));
}
代码示例来源:origin: com.caucho/resin
/**
* Process the tag.
*/
public int doStartTag()
throws JspException
{
if (_valueExpr == null)
return EVAL_BODY_BUFFERED;
PageContextImpl pageContext = (PageContextImpl) this.pageContext;
Object value = _valueExpr.evalObject(pageContext.getELContext());
Tag parent = getParent();
for (;
parent != null && ! (parent instanceof SQLExecutionTag);
parent = parent.getParent()) {
}
if (parent == null)
throw new JspException(L.l("sql:param requires sql:query parent."));
SQLExecutionTag tag = (SQLExecutionTag) parent;
tag.addSQLParameter(value);
return SKIP_BODY;
}
内容来源于网络,如有侵权,请联系作者删除!