当前位置: 首页>>代码示例>>Java>>正文


Java Tag.getParent方法代码示例

本文整理汇总了Java中javax.servlet.jsp.tagext.Tag.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java Tag.getParent方法的具体用法?Java Tag.getParent怎么用?Java Tag.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.servlet.jsp.tagext.Tag的用法示例。


在下文中一共展示了Tag.getParent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hasAncestorOfType

import javax.servlet.jsp.tagext.Tag; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:TagUtils.java

示例2: getParentTag

import javax.servlet.jsp.tagext.Tag; //导入方法依赖的package包/类
/**
    * <p>Locates the enclosing tag of the type supplied.  If no enclosing tag of the type supplied
    * can be found anywhere in the ancestry of this tag, null is returned.</p>
    *
    * @return T Tag of the type supplied, or null if none can be found
    */
   @SuppressWarnings("unchecked")
protected <T extends Tag> T getParentTag(Class<T> tagType) {
       Tag parent = getParent();
       while (parent != null) {
           if (tagType.isAssignableFrom(parent.getClass())) {
               return (T) parent;
           }
           parent = parent.getParent();
       }

       // If we can't find it by the normal way, try our own tag stack!
       Stack<StripesTagSupport> stack = getTagStack();
       ListIterator<StripesTagSupport> iterator = stack.listIterator(stack.size());
       while (iterator.hasPrevious() && iterator.previous() != this) continue;
       while (iterator.hasPrevious()) {
           StripesTagSupport tag = iterator.previous();
           if (tagType.isAssignableFrom(tag.getClass())) {
               return (T) tag;
           }
       }

       return null;
   }
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:30,代码来源:StripesTagSupport.java

示例3: doEndTag

import javax.servlet.jsp.tagext.Tag; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:28,代码来源:ParamTag.java

示例4: findAncestorWithClass

import javax.servlet.jsp.tagext.Tag; //导入方法依赖的package包/类
/**
 * 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.
 * 
 * <p>
 * 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.
 * 
 * <p>
 * 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.
 * 
 * 
 * @param from
 *          The instance from where to start looking.
 * @param klass
 *          The subclass of Tag or interface to be matched
 * @return the nearest ancestor that implements the interface or is an
 *         instance of the class specified
 */
public static final Tag findAncestorWithClass(Tag from,
// TCK signature test fails with generics
    @SuppressWarnings("unchecked") Class klass)
{
  boolean isInterface = false;

  if (from == null
      || klass == null
      || (!Tag.class.isAssignableFrom(klass) && !(isInterface = klass
          .isInterface())))
  {
    return null;
  }

  for (;;)
  {
    Tag tag = from.getParent();

    if (tag == null)
    {
      return null;
    }

    if ((isInterface && klass.isInstance(tag))
        || klass.isAssignableFrom(tag.getClass()))
      return tag;
    else
      from = tag;
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:61,代码来源:TrinidadTagSupport.java

示例5: getCurrentName

import javax.servlet.jsp.tagext.Tag; //导入方法依赖的package包/类
/**
 * <p>Returns the bean name from the request object that the properties are
 * nesting against.</p>
 *
 * <p>The requirement of the tag itself could be removed in the future, but is
 * required if support for the <html:form> tag is maintained.</p>
 * @param request object to fetch the bean reference from
 * @param nested tag from which to start the search from
 * @return the string of the bean name to be nesting against
 */
public static final String getCurrentName(HttpServletRequest request,
                                          NestedNameSupport nested) {
  // get the old one if any
  NestedReference nr = (NestedReference) request.getAttribute(NESTED_INCLUDES_KEY);
  // return null or the property
  if (nr != null) {
    return nr.getBeanName();

  } else {
    // need to look for a form tag...
    Tag tag = (Tag) nested;
    Tag formTag = null;

    // loop all parent tags until we get one that can be nested against
    do {
      tag = tag.getParent();
      if (tag != null && tag instanceof FormTag) {
        formTag = tag;
      }
    } while (formTag == null && tag != null);

    if (formTag == null) {
      return "";
    }
    // return the form's name
    return ((FormTag) formTag).getBeanName();
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:39,代码来源:NestedPropertyHelper.java

示例6: getCurrentName

import javax.servlet.jsp.tagext.Tag; //导入方法依赖的package包/类
/**
 * <p>Returns the bean name from the request object that the properties
 * are nesting against.</p>
 *
 * <p>The requirement of the tag itself could be removed in the future,
 * but is required if support for the <html:form> tag is maintained.</p>
 *
 * @param request object to fetch the bean reference from
 * @param nested  tag from which to start the search from
 * @return the string of the bean name to be nesting against
 */
public static final String getCurrentName(HttpServletRequest request,
    NestedNameSupport nested) {
    // get the old one if any
    NestedReference nr =
        (NestedReference) request.getAttribute(NESTED_INCLUDES_KEY);

    // return null or the property
    if (nr != null) {
        return nr.getBeanName();
    } else {
        // need to look for a form tag...
        Tag tag = (Tag) nested;
        Tag formTag = null;

        // loop all parent tags until we get one that can be nested against
        do {
            tag = tag.getParent();

            if ((tag != null) && tag instanceof FormTag) {
                formTag = tag;
            }
        } while ((formTag == null) && (tag != null));

        if (formTag == null) {
            return "";
        }

        // return the form's name
        return ((FormTag) formTag).getBeanName();
    }
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:43,代码来源:NestedPropertyHelper.java


注:本文中的javax.servlet.jsp.tagext.Tag.getParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。