1 25 26 package org.objectweb.jonas.webapp.taglib; 27 28 import javax.servlet.jsp.JspException ; 29 30 33 public class GridTag extends GridTableBaseTag { 34 35 37 private int m_iRow = 0; 38 private boolean m_bEvenRow = false; 39 40 42 private String oddStyleClass = null; 43 private String evenStyleClass = null; 44 private String globalRowStyleClass = null; 45 private int periodRow = 1; 46 private int border = 0; 47 private int cellSpacing = 0; 48 private int cellPadding = 0; 49 50 53 public String getOddStyleClass() { 54 return oddStyleClass; 55 } 56 57 62 public void setOddStyleClass(String styleClass) { 63 this.oddStyleClass = styleClass; 64 } 65 66 69 70 73 public String getEvenStyleClass() { 74 return evenStyleClass; 75 } 76 77 82 public void setEvenStyleClass(String styleClass) { 83 this.evenStyleClass = styleClass; 84 } 85 86 public int getPeriodRow() { 87 return periodRow; 88 } 89 90 public void setPeriodRow(int periodRow) { 91 this.periodRow = periodRow; 92 } 93 public void setPeriodRow(String p_PeriodRow) { 94 this.periodRow = Integer.parseInt(p_PeriodRow); 95 } 96 97 public int getBorder() { 98 return border; 99 } 100 101 public void setBorder(int border) { 102 this.border = border; 103 } 104 105 public int getCellSpacing() { 106 return cellSpacing; 107 } 108 109 public void setCellSpacing(int cellSpacing) { 110 this.cellSpacing = cellSpacing; 111 } 112 113 public int getCellPadding() { 114 return cellPadding; 115 } 116 117 public void setCellPadding(int cellPadding) { 118 this.cellPadding = cellPadding; 119 } 120 121 public String getGlobalRowStyleClass() { 122 return globalRowStyleClass; 123 } 124 125 public void setGlobalRowStyleClass(String globalRowStyleClass) { 126 this.globalRowStyleClass = globalRowStyleClass; 127 } 128 129 131 136 public int doStartTag() 137 throws JspException { 138 m_bEvenRow = false; 139 m_iRow = 0; 140 return super.doStartTag(); 141 } 142 143 146 public void release() { 147 super.release(); 148 m_iRow = 0; 149 m_bEvenRow = false; 150 151 oddStyleClass = null; 152 evenStyleClass = null; 153 globalRowStyleClass = null; 154 periodRow = 1; 155 156 border = 0; 157 cellSpacing = 0; 158 cellPadding = 0; 159 } 163 164 166 169 protected String prepareAttributes() throws JspException { 170 StringBuffer sb = new StringBuffer (); 171 172 sb.append(prepareAttribute("border", border)); 174 sb.append(prepareAttribute("cellspacing", cellSpacing)); 176 sb.append(prepareAttribute("cellpadding", cellPadding)); 178 179 sb.append(super.prepareAttributes()); 181 182 return sb.toString(); 183 184 } 185 186 protected String getRowStyle(boolean p_bChange) { 187 if (globalRowStyleClass == null) { 188 if (periodRow > 0) { 189 if (m_iRow >= periodRow) { 190 m_bEvenRow = !m_bEvenRow; 191 m_iRow = 0; 192 } 193 m_iRow++; 194 } 195 if (p_bChange == true) { 196 m_bEvenRow = !m_bEvenRow; 197 m_iRow = 1; 198 } 199 if (m_bEvenRow == true) { 200 return evenStyleClass; 201 } 202 return oddStyleClass; 203 } 204 return globalRowStyleClass; 205 } 206 } | Popular Tags |