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 TRTag.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 TRTag extends TableBase {

 private String nowrap = null;

 private String valign = null;

 /**
  * styleClass1_TD and styleClass2_TD associated with TD tag
  */
 private String styleClass1_TD = null;

 private String styleClass2_TD = null;

 private int currentClass = -1;

 public String getNowrap() {
  return nowrap;
 }

 public void setNowrap(String nowrap) {
  this.nowrap = nowrap;
 }

 public String getValign() {
  return valign;
 }

 public void setValign(String valign) {
  this.valign = valign;
 }

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

  if (valign != null && !valign.trim().equals("")) {
   handlers.append("  VALIGN=/"" + valign + "/"");
  }

 } // end setTRCommonAttributes

 /**
  * write tr header and  attributes and set partial values of buffer storage
  * p><code>writeTRHeaders</code></p>
  * @throws JspException
  * @author david 2004-12-7
  * @Since 1.0
  */
 public void writeTRHeaders() throws JspException {
  validateDir();
  if (pageContext.getAttribute("currentTRCLASS") != null) {
   currentClass =
    Integer.parseInt(
     pageContext.getAttribute("currentTRCLASS").toString());
   if (currentClass % 2 == 0) {
    styleClass = pageContext.getAttribute("TRCALSS1").toString();
   } else {
    styleClass = pageContext.getAttribute("TRCALSS2").toString();
   }
  }
  StringBuffer buf = new StringBuffer("<TR");
  setT_ID(buf);
  setTRCommonAttributes(buf);
  prepareEvents_T(buf);
  buf.append(">");
  if (styleClass1_TD != null
   && styleClass2_TD != null
   && !styleClass1_TD.trim().equals("")
   && !styleClass2_TD.trim().equals("")) {
   pageContext.setAttribute("TDCALSS1", styleClass1_TD);
   pageContext.setAttribute("TDCALSS2", styleClass2_TD);
   pageContext.setAttribute("currentCLASS", "0");
  }
  ResponseUtils.write(pageContext, buf.toString());
 } // end writeTRHeaders

 /**
  * write tr latter end and clear partial values of buffer storage
  * p><code>writeTREnd</code></p>
  * @throws JspException
  * @author david 2004-12-7
  * @Since 1.0
  */
 public void writeTREnd() throws JspException {
  StringBuffer buf = new StringBuffer("</TR>/n");
  if (styleClass1_TD != null) {
   pageContext.removeAttribute("TDCALSS1");
   pageContext.removeAttribute("TDCALSS2");
   pageContext.removeAttribute("currentCLASS");
  }
  if (currentClass > -1) {
   pageContext.setAttribute(
    "currentTRCLASS",
    String.valueOf(currentClass + 1));
  }
  ResponseUtils.write(pageContext, buf.toString());
 } // end writeTREnd

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

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

 /**
  * Release all allocated resources.
  */
 public void release() {
  super.release();
  nowrap = null;
  valign = null;
  styleClass1_TD = null;
  styleClass2_TD = null;
  currentClass = -1;
 } // end release

 public String getStyleClass1_TD() {
  return styleClass1_TD;
 }

 public void setStyleClass1_TD(String styleClass1_TD) {
  this.styleClass1_TD = styleClass1_TD;
 }

 public String getStyleClass2_TD() {
  return styleClass2_TD;
 }

 public void setStyleClass2_TD(String styleClass2_TD) {
  this.styleClass2_TD = styleClass2_TD;
 }
} // end TRTag 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值