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

15 篇文章 0 订阅

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
 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值