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

来源:互联网 发布:yum install package 编辑:程序博客网 时间:2024/05/03 10:38

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
 

原创粉丝点击