Esempio n. 1
0
  /**
   * Passes attribute information up to the parent TableTag.
   *
   * <p>When we hit the end of the tag, we simply let our parent (which better be a TableTag) know
   * what the user wants to do with this column. We do that by simple registering this tag with the
   * parent. This tag's only job is to hold the configuration information to describe this
   * particular column. The TableTag does all the work.
   *
   * @return int
   * @throws JspException if this tag is being used outside of a &lt;display:list...&gt; tag.
   * @see javax.servlet.jsp.tagext.Tag#doEndTag()
   */
  public int doEndTag() throws JspException {
    TableTag tableTag = getTableTag();

    MediaTypeEnum currentMediaType =
        (MediaTypeEnum) this.pageContext.findAttribute(TableTag.PAGE_ATTRIBUTE_MEDIA);
    if (currentMediaType != null && !MediaUtil.availableForMedia(this, currentMediaType)) {
      if (log.isDebugEnabled()) {
        log.debug("skipping column body, currentMediaType=" + currentMediaType);
      }
      return SKIP_BODY;
    }

    // add column header only once
    if (tableTag.isFirstIteration()) {
      addHeaderToTable(tableTag);
    }

    if (!tableTag.isIncludedRow()) {
      return super.doEndTag();
    }

    Cell cell = null;
    if (this.property == null && this.value != null) {
      cell = new Cell(value);
    } else if (this.property == null && this.bodyContent != null) {
      cell = new Cell(this.bodyContent.getString());
    }

    Object rowStyle = this.attributeMap.get(TagConstants.ATTRIBUTE_STYLE);
    Object rowClass = this.attributeMap.get(TagConstants.ATTRIBUTE_CLASS);
    if (rowStyle != null || rowClass != null) {
      HtmlAttributeMap perRowValues = new HtmlAttributeMap();
      if (rowStyle != null) {
        perRowValues.put(TagConstants.ATTRIBUTE_STYLE, rowStyle);
      }
      if (rowClass != null) {
        perRowValues.put(TagConstants.ATTRIBUTE_CLASS, rowClass);
      }
      if (cell == null) {
        cell = new Cell(null);
      }
      cell.setPerRowAttributes(perRowValues);
    }

    tableTag.addCell(cell != null ? cell : Cell.EMPTY_CELL);

    // cleanup non-attribute variables
    this.alreadySorted = false;

    return super.doEndTag();
  }
Esempio n. 2
0
  /** @see javax.servlet.jsp.tagext.Tag#doStartTag() */
  public int doStartTag() throws JspException {
    TableTag tableTag = getTableTag();
    if (tableTag == null) {
      throw new TagStructureException(getClass(), "column", "table");
    }

    // If the list is empty, do not execute the body; may result in NPE
    if (tableTag.isEmpty() || !tableTag.isIncludedRow()) {
      return SKIP_BODY;
    }

    MediaTypeEnum currentMediaType =
        (MediaTypeEnum) this.pageContext.findAttribute(TableTag.PAGE_ATTRIBUTE_MEDIA);
    if (!MediaUtil.availableForMedia(this, currentMediaType)) {
      return SKIP_BODY;
    }

    return super.doStartTag();
  }