/** * 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; }
/** * 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; }
Tag tag = from.getParent();
parent = ((Tag)from).getParent();
Tag tag = from.getParent();
parent = ((Tag)from).getParent();
/** * Delegates to wrapped tag. */ public Tag getParent() { return tag.getParent(); }
/** * Delegates to wrapped tag. */ public Tag getParent() { return tag.getParent(); }
/** * Delegates to wrapped tag. */ public Tag getParent() { return tag.getParent(); }
/** * 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; }
/** * 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; }
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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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); }
for (; parent != null && ! (parent instanceof SQLExecutionTag); parent = parent.getParent()) {
/** * 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.")); }
/** * 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; }