原创  jsp使用自定义标签taglib分页系列——TDTag.java收藏

新一篇:  jsp使用自定义标签taglib分页系列——ContentBase.java | 旧一篇:  jsp使用自定义标签taglib分页系列——TRTag.java

package com.avantouch.common.web.struts.taglib.table;

import javax.servlet.jsp.JspException;

import org.apache.struts.util.ResponseUtils;

/**
 * <p>Title TDTag.java</p>
 * <p>Description  </p>
 * <p>Copyright:  Copyright (c) 2004 AvanTouch,Inc</p>
 * <p>Company:  AvanTouch,Inc</p>
 * @author:  david 2004-12-6
 * @modifier:
 * @version  1.0
 */
public class TDTag extends TableBase {

 private String abbr = null;
 private String axis = null;
 private String backgroud = null;
 private String colspan = null;
 private String headers = null;
 private String nowrap = null;
 private String rowspan = null;
 private String valign = null;
 private String width = null;

 private int currentClass = -1;

 public String getAbbr() {
  return abbr;
 }
 public void setAbbr(String abbr) {
  this.abbr = abbr;
 }
 public String getAxis() {
  return axis;
 }
 public void setAxis(String axis) {
  this.axis = axis;
 }
 public String getBackgroud() {
  return backgroud;
 }
 public void setBackgroud(String backgroud) {
  this.backgroud = backgroud;
 }
 public String getColspan() {
  return colspan;
 }
 public void setColspan(String colspan) {
  this.colspan = colspan;
 }
 public String getHeaders() {
  return headers;
 }
 public void setHeaders(String headers) {
  this.headers = headers;
 }
 public String getNowrap() {
  return nowrap;
 }
 public void setNowrap(String nowrap) {
  this.nowrap = nowrap;
 }
 public String getRowspan() {
  return rowspan;
 }
 public void setRowspan(String rowspan) {
  this.rowspan = rowspan;
 }
 public String getValign() {
  return valign;
 }
 public void setValign(String valign) {
  this.valign = valign;
 }
 public String getWidth() {
  return width;
 }
 public void setWidth(String width) {
  this.width = width;
 }

 /**
  * write td header and  attributes and set partial values of buffer storage
  * p><code>writeTDHeaders</code></p>
  * @throws JspException
  * @author david 2004-12-7
  * @Since 1.0
  */
 public void writeTDHeaders() throws JspException {
  validateDir();
  if (pageContext.getAttribute("currentCLASS") != null) {
   currentClass =
    Integer.parseInt(
     pageContext.getAttribute("currentCLASS").toString());
   if (currentClass % 2 == 0) {
    styleClass = pageContext.getAttribute("TDCALSS1").toString();
   } else {
    styleClass = pageContext.getAttribute("TDCALSS2").toString();
   }
  }
  StringBuffer buf = new StringBuffer("<TD");
  setT_ID(buf);
  setTDCommonAttributes(buf);
  prepareEvents_T(buf);
  buf.append(">");
  ResponseUtils.write(pageContext, buf.toString());
 } // end writeTDHeaders

 /**
  * write td latter end and reinstall partial values of buffer storage
  * p><code>writeTDEnd</code></p>
  * @throws JspException
  * @author david 2004-12-7
  * @Since 1.0
  */
 public void writeTDEnd() throws JspException {
  StringBuffer buf = new StringBuffer("</TD>");

  ResponseUtils.write(pageContext, buf.toString());
  if (currentClass > -1) {
   pageContext.setAttribute(
    "currentCLASS",
    String.valueOf(currentClass + 1));
  }
 } // end writeTDEnd

 public int doStartTag() throws JspException {
  writeTDHeaders();
  return (EVAL_BODY_INCLUDE);
 }

 public int doEndTag() throws JspException {
  writeTDEnd();
  release();
  // Continue processing this page
  return (EVAL_PAGE);
 }

 /**
  * set td common attributes value
  * <p><code>setTDCommonAttributes</code></p>
  * @param handlers
  * @author david 2004-12-6
  * @Since 1.0
  */
 public void setTDCommonAttributes(StringBuffer handlers) {
  if (nowrap != null) {
   if (Boolean.valueOf(nowrap).booleanValue()) {
    handlers.append("  nowrap");
   }
  }
  setT_CommonAttributes(handlers);

  if (width != null && !width.trim().equals("")) {
   handlers.append("  WIDTH=\"" + width + "\"");
  }

  if (abbr != null && !abbr.trim().equals("")) {
   handlers.append("  ABBR=\"" + abbr + "\"");
  }
  if (axis != null && !axis.trim().equals("")) {
   handlers.append("  AXIS=\"" + axis + "\"");
  }
  if (backgroud != null && !backgroud.trim().equals("")) {
   handlers.append("  BACKGROUD=\"" + backgroud + "\"");
  }
  if (colspan != null && !colspan.trim().equals("")) {
   handlers.append("  COLSPAN=\"" + colspan + "\"");
  }
  if (headers != null && !headers.trim().equals("")) {
   handlers.append("  HEADERS=\"" + headers + "\"");
  }
  if (rowspan != null && !rowspan.trim().equals("")) {
   handlers.append("  ROWSPAN=\"" + rowspan + "\"");
  }
  if (valign != null && !valign.trim().equals("")) {
   handlers.append("  VALIGN=\"" + valign + "\"");
  }

 } // end setTDCommonAttributes

 /**
  * Release all allocated resources.
  */
 public void release() {
  super.release();
  abbr = null;
  axis = null;
  backgroud = null;
  colspan = null;
  headers = null;
  nowrap = null;
  rowspan = null;
  valign = null;
  width = null;
  currentClass = -1;
 } // end release

} // end TDTag
 

发表于 @ 2007年06月15日 11:33:00|评论(loading...)|编辑

新一篇:  jsp使用自定义标签taglib分页系列——ContentBase.java | 旧一篇:  jsp使用自定义标签taglib分页系列——TRTag.java

评论:没有评论。

发表评论  


当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
Csdn Blog version 3.1a
Copyright © cao_david