Java Code Examples for javax.servlet.jsp.tagext.Tag#getParent()

The following examples show how to use javax.servlet.jsp.tagext.Tag#getParent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TagUtils.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example 2
Source File: TagUtils.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: TagUtils.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 4
Source File: TagUtils.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: URLParTag.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public int doEndTag() throws JspException {
	BodyContent body = this.getBodyContent();
	String value = body.getString();
	URLTag parentTag = null;
	try {
		Tag tag = this;
		do {
			tag = tag.getParent();
		} while (!(tag instanceof URLTag));
		parentTag = (URLTag) tag;
	} catch (RuntimeException e) {
		throw new JspException("Error nesting parameter in url tag.", e);
	}
	parentTag.addParameter(this.getName(), value);
	return EVAL_PAGE;
}
 
Example 6
Source File: ColumnTag.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the ListDisplayTag that serves as the parent tag.
 * Returns null if no ListDisplayTag is found.
 * @return the parent ListDisplayTag
 */
public UnpagedListDisplayTag findUnpagedListDisplay() {
    Tag tagParent = getParent();
    while (tagParent != null && !(tagParent instanceof UnpagedListDisplayTag)) {
        tagParent = tagParent.getParent();
    }
    return (UnpagedListDisplayTag) tagParent;
}
 
Example 7
Source File: ColumnTag.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the ListDisplayTag that serves as the parent tag.
 * Returns null if no ListDisplayTag is found.
 * @return the parent ListDisplayTag
 */
public ListDisplayTag findListDisplay() {
    Tag tagParent = getParent();
    while (tagParent != null && !(tagParent instanceof ListDisplayTag)) {
        tagParent = tagParent.getParent();
    }
    return (ListDisplayTag) tagParent;
}
 
Example 8
Source File: ColumnTag.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the ListDisplayTag that serves as the parent tag.
 * Returns null if no ListDisplayTag is found.
 * @return the parent ListDisplayTag
 */
public UnpagedListDisplayTag findUnpagedListDisplay() {
    Tag tagParent = getParent();
    while (tagParent != null && !(tagParent instanceof UnpagedListDisplayTag)) {
        tagParent = tagParent.getParent();
    }
    return (UnpagedListDisplayTag) tagParent;
}
 
Example 9
Source File: ColumnTag.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the ListDisplayTag that serves as the parent tag.
 * Returns null if no ListDisplayTag is found.
 * @return the parent ListDisplayTag
 */
public ListDisplayTag findListDisplay() {
    Tag tagParent = getParent();
    while (tagParent != null && !(tagParent instanceof ListDisplayTag)) {
        tagParent = tagParent.getParent();
    }
    return (ListDisplayTag) tagParent;
}