GridTag.java

00001 /*
00002  * JOnAS: Java(TM) Open Application Server
00003  * Copyright (C) 1999 Bull S.A.
00004  * Contact: jonas-team@objectweb.org
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00019  * USA
00020  *
00021  * --------------------------------------------------------------------------
00022  * $Id: GridTag.java,v 1.5 2004/03/26 16:16:12 benoitf Exp $
00023  * --------------------------------------------------------------------------
00024  */
00025 
00026 package org.objectweb.jonas.webapp.taglib;
00027 
00028 import javax.servlet.jsp.JspException;
00029 
00033 public class GridTag extends GridTableBaseTag {
00034 
00035 // ----------------------------------------------------- Instance Variables
00036 
00037     private int m_iRow = 0;
00038     private boolean m_bEvenRow = false;
00039 
00040 // ----------------------------------------------------- Properties
00041 
00042     private String oddStyleClass = null;
00043     private String evenStyleClass = null;
00044     private String globalRowStyleClass = null;
00045     private int periodRow = 1;
00046     private int border = 0;
00047     private int cellSpacing = 0;
00048     private int cellPadding = 0;
00049 
00053     public String getOddStyleClass() {
00054         return oddStyleClass;
00055     }
00056 
00062     public void setOddStyleClass(String styleClass) {
00063         this.oddStyleClass = styleClass;
00064     }
00065 
00073     public String getEvenStyleClass() {
00074         return evenStyleClass;
00075     }
00076 
00082     public void setEvenStyleClass(String styleClass) {
00083         this.evenStyleClass = styleClass;
00084     }
00085 
00086     public int getPeriodRow() {
00087         return periodRow;
00088     }
00089 
00090     public void setPeriodRow(int periodRow) {
00091         this.periodRow = periodRow;
00092     }
00093     public void setPeriodRow(String p_PeriodRow) {
00094         this.periodRow = Integer.parseInt(p_PeriodRow);
00095     }
00096 
00097     public int getBorder() {
00098         return border;
00099     }
00100 
00101     public void setBorder(int border) {
00102         this.border = border;
00103     }
00104 
00105     public int getCellSpacing() {
00106         return cellSpacing;
00107     }
00108 
00109     public void setCellSpacing(int cellSpacing) {
00110         this.cellSpacing = cellSpacing;
00111     }
00112 
00113     public int getCellPadding() {
00114         return cellPadding;
00115     }
00116 
00117     public void setCellPadding(int cellPadding) {
00118         this.cellPadding = cellPadding;
00119     }
00120 
00121     public String getGlobalRowStyleClass() {
00122         return globalRowStyleClass;
00123     }
00124 
00125     public void setGlobalRowStyleClass(String globalRowStyleClass) {
00126         this.globalRowStyleClass = globalRowStyleClass;
00127     }
00128 
00129 // ----------------------------------------------------- Public Methods
00130 
00136     public int doStartTag()
00137         throws JspException {
00138         m_bEvenRow = false;
00139         m_iRow = 0;
00140         return super.doStartTag();
00141     }
00142 
00146     public void release() {
00147         super.release();
00148         m_iRow = 0;
00149         m_bEvenRow = false;
00150 
00151         oddStyleClass = null;
00152         evenStyleClass = null;
00153         globalRowStyleClass = null;
00154         periodRow = 1;
00155 
00156         border = 0;
00157         cellSpacing = 0;
00158         cellPadding = 0;
00159         //border = -1;
00160         //cellSpacing = -1;
00161         //cellPadding = -1;
00162     }
00163 
00164 // ----------------------------------------------------- Protected Methods
00165 
00169     protected String prepareAttributes() throws JspException {
00170         StringBuffer sb = new StringBuffer();
00171 
00172         // Append "border" parameter
00173         sb.append(prepareAttribute("border", border));
00174         // Append "cellspacing" parameter
00175         sb.append(prepareAttribute("cellspacing", cellSpacing));
00176         // Append "cellpadding" parameter
00177         sb.append(prepareAttribute("cellpadding", cellPadding));
00178 
00179         // Append Event Handler details
00180         sb.append(super.prepareAttributes());
00181 
00182         return sb.toString();
00183 
00184     }
00185 
00186     protected String getRowStyle(boolean p_bChange) {
00187         if (globalRowStyleClass == null) {
00188             if (periodRow > 0) {
00189                 if (m_iRow >= periodRow) {
00190                     m_bEvenRow = !m_bEvenRow;
00191                     m_iRow = 0;
00192                 }
00193                 m_iRow++;
00194             }
00195             if (p_bChange == true) {
00196                 m_bEvenRow = !m_bEvenRow;
00197                 m_iRow = 1;
00198             }
00199             if (m_bEvenRow == true) {
00200                 return evenStyleClass;
00201             }
00202             return oddStyleClass;
00203         }
00204         return globalRowStyleClass;
00205     }
00206 }

Generated on Tue Feb 15 15:05:34 2005 for JOnAS by  doxygen 1.3.9.1