1 package fr.improve.struts.taglib.layout.util; 2 3 import javax.servlet.jsp.JspException ; 4 import javax.servlet.jsp.PageContext ; 5 import javax.servlet.jsp.tagext.TagSupport ; 6 7 import fr.improve.struts.taglib.layout.collection.CollectionItemTag; 8 import fr.improve.struts.taglib.layout.collection.CollectionTag; 9 import fr.improve.struts.taglib.layout.el.Expression; 10 11 16 public class FixedHeaderCollection extends BasicPanel implements CollectionInterface, IMathCollectionRenderer, IFooterRenderer, IMultiLevelHeaderRenderer { 17 protected CollectionTag collectionTag; 18 protected PageContext pageContext; 19 20 public void init(PageContext pg, String in_styleClass, TagSupport in_tag) throws JspException { 21 super.init(pg, in_styleClass, in_tag); 22 collectionTag = (CollectionTag) in_tag; 23 pageContext = pg; 24 } 25 26 29 public void doPrintEmptyCollection(StringBuffer out_buffer, String in_message) { 30 out_buffer.append("<tr><td colspan=\""); 31 out_buffer.append(collectionTag.getHeaders().size()); 32 out_buffer.append("\" class=\""); 33 out_buffer.append(styleClass); 34 out_buffer.append("\"> "); 35 out_buffer.append(in_message); 36 out_buffer.append("</td></tr>"); 37 } 38 42 public void doPrintTitle(StringBuffer buffer, String title) { 43 if (title!=null) { 44 if (styleClass!=null) { 45 buffer.append("<p class=\""); 46 buffer.append(styleClass); 47 buffer.append("\">"); 48 } 49 buffer.append(title); 50 if (styleClass!=null) { 51 buffer.append("</p>"); 52 } 53 } 55 } 56 59 public void doStartPanel(StringBuffer buffer, String align, String width) { 60 if (collectionTag.getWidth()!=null || collectionTag.getHeight()!=null) { 61 buffer.append("<div style=\""); 62 if (collectionTag.getWidth()!=null && collectionTag.getHeight()!=null) { 63 buffer.append("width:"); 64 buffer.append(collectionTag.getWidth()); 65 buffer.append("px;"); 66 buffer.append("height:"); 67 buffer.append(collectionTag.getHeight()); 68 buffer.append("px;"); 69 buffer.append("overflow:auto;"); 70 } else { 71 if (collectionTag.getWidth()!=null) { 72 buffer.append("width:"); 73 buffer.append(collectionTag.getWidth()); 74 buffer.append("px;"); 75 buffer.append("overflow-x:auto;"); 76 } 77 if (collectionTag.getHeight()!=null) { 78 buffer.append("height:"); 79 buffer.append(collectionTag.getHeight()); 80 buffer.append("px;"); 81 buffer.append("overflow-y:auto;overflow:-moz-scrollbars-vertical;"); 82 } 83 } 84 buffer.append("\">"); 85 } 86 buffer.append("<table"); 87 if (align!=null) { 88 buffer.append(" align=\""); 89 buffer.append(align); 90 buffer.append("\""); 91 } 92 if (width!=null) { 93 buffer.append(" width=\""); 94 buffer.append(width); 95 buffer.append("\""); 96 } 97 if (styleClass!=null) { 98 buffer.append(" class=\""); 99 buffer.append(styleClass); 100 buffer.append("\""); 101 } 102 if (collectionTag.getStyleId()!=null) { 103 buffer.append(" id=\""); 104 buffer.append(collectionTag.getStyleId()); 105 buffer.append("\""); 106 } 107 buffer.append(">\n"); 108 } 109 112 public void doStartHeaders(StringBuffer out_buffer) { 113 out_buffer.append("<tr id=\"head\">"); 114 } 115 118 public void doPrintHeader(StringBuffer out_buffer, String in_header, String in_width, String in_sortUrl) { 119 out_buffer.append("<th"); 120 if (styleClass!=null) { 121 out_buffer.append(" class=\""); 122 out_buffer.append(styleClass); 123 out_buffer.append("\""); 124 } 125 if (in_width!=null) { 126 out_buffer.append(" width=\""); 127 out_buffer.append(in_width); 128 out_buffer.append("\""); 129 } 130 out_buffer.append(">"); 131 132 out_buffer.append(doPrintSortUrl(in_header, in_sortUrl)); 133 134 135 out_buffer.append("</th>"); 136 } 137 138 141 protected String doPrintSortUrl(String in_header, String in_sortUrl) { 142 if (in_sortUrl == null) { 143 return in_header; 144 } 145 else if (collectionTag.getSortPictogram().equalsIgnoreCase("none")) { 146 StringBuffer lc_tempBuffer = new StringBuffer ("<table border=\"0\" width=\"100%\"><tr><td>"); 148 lc_tempBuffer.append(" "); 149 lc_tempBuffer.append("</td><td>"); 150 lc_tempBuffer.append("<a HREF=\""); 151 lc_tempBuffer.append(in_sortUrl); 152 lc_tempBuffer.append("\">"); 153 lc_tempBuffer.append(in_header); 154 lc_tempBuffer.append("</a>"); 155 lc_tempBuffer.append("</td></tr></table>"); 156 return lc_tempBuffer.toString(); 157 } 158 else { 159 StringBuffer lc_tempBuffer = new StringBuffer ("<table border=\"0\" width=\"100%\"><tr><td>"); 161 lc_tempBuffer.append("<a HREF=\""); 162 lc_tempBuffer.append(in_sortUrl); 163 lc_tempBuffer.append("\"><img SRC=\""); 164 lc_tempBuffer.append(LayoutUtils.getSkin(pageContext.getSession()).getImageDirectory(pageContext.getRequest())); 165 lc_tempBuffer.append("/"); 166 lc_tempBuffer.append(LayoutUtils.getSkin(pageContext.getSession()).getProperty(collectionTag.getSortPictogram())); 167 lc_tempBuffer.append("\" border=\"0\" alt=\""); 168 lc_tempBuffer.append(LayoutUtils.getSkin(pageContext.getSession()).getProperty(collectionTag.getSortLabel())); 169 lc_tempBuffer.append("\"></a>"); 170 171 lc_tempBuffer.append("</td><td>"); 172 lc_tempBuffer.append(in_header); 173 lc_tempBuffer.append("</td></tr></table>"); 174 175 return lc_tempBuffer.toString(); 176 } 177 } 178 179 180 183 public void doEndHeaders(StringBuffer out_buffer) { 184 out_buffer.append("</tr>"); 185 } 186 189 public void doStartItems(StringBuffer out_buffer) { 190 out_buffer.append("<tr"); 191 boolean lc_onclick = false; 192 if (collectionTag.getOnRowClick()!=null) { 193 out_buffer.append(" onclick=\""); 194 out_buffer.append(Expression.evaluate(collectionTag.getOnRowClick(), pageContext)); 195 out_buffer.append("\""); 196 lc_onclick = true; 197 } 198 if (collectionTag.getOnRowDblClick()!=null) { 199 out_buffer.append(" ondblclick=\""); 200 out_buffer.append(Expression.evaluate(collectionTag.getOnRowDblClick(), pageContext)); 201 out_buffer.append("\""); 202 lc_onclick = true; 203 } 204 if (collectionTag.getOnRowMouseOver()!=null) { 205 out_buffer.append(" onmouseover=\""); 206 out_buffer.append(Expression.evaluate(collectionTag.getOnRowMouseOver(), pageContext)); 207 out_buffer.append("\""); 208 lc_onclick = true; 209 } 210 if (collectionTag.getOnRowMouseOut()!=null) { 211 out_buffer.append(" onmouseout=\""); 212 out_buffer.append(Expression.evaluate(collectionTag.getOnRowMouseOut(), pageContext)); 213 out_buffer.append("\""); 214 } 215 if (lc_onclick) { 216 out_buffer.append(" style=\"cursor:pointer;cursor:hand;\""); 217 } 218 out_buffer.append(">"); 219 } 220 223 public void doPrintItem(StringBuffer out_buffer, String in_item, String [] in_styleClass, String in_id) { 224 out_buffer.append("<td"); 225 if (in_styleClass[0] != null) { 226 out_buffer.append(" class=\""); 227 out_buffer.append(in_styleClass[0]); 228 out_buffer.append("\""); 229 } 230 if (in_styleClass.length>1) { 231 out_buffer.append(" style=\""); 232 for (int i = 0; i < in_styleClass.length-1; i++) { 233 out_buffer.append(in_styleClass[i+1]); 234 } 235 out_buffer.append("\""); 236 } 237 238 Integer lc_int = (Integer ) pageContext.getAttribute(CollectionItemTag.SPAN_KEY); 239 if (lc_int!=null && lc_int.intValue()!=1) { 240 out_buffer.append(" rowspan=\""); 241 out_buffer.append(lc_int.intValue()); 242 out_buffer.append("\""); 243 } 244 245 out_buffer.append(">"); 246 247 if (in_id!=null) { 248 out_buffer.append("<div id=\""); 249 out_buffer.append(in_id); 250 out_buffer.append("\">"); 251 } 252 253 out_buffer.append(in_item); 254 255 if (in_id!=null) { 256 out_buffer.append("</div>"); 257 } 258 259 out_buffer.append("</td>"); 260 } 261 264 public void doEndItems(StringBuffer out_buffer) { 265 out_buffer.append("</tr>"); 266 } 267 public void doEndPanel(StringBuffer buffer) { 268 buffer.append("</table>\n"); 269 if (collectionTag.getWidth()!=null || collectionTag.getHeight()!=null) { 270 buffer.append("</div>"); 271 272 String lc_id = WidgetUtils.generateId(pageContext.getRequest(), "collectionLayerId"); 274 buffer.append("<div style=\"position:absolute;top:0;left:0\" id=\"colLayer"); 275 buffer.append(lc_id); 276 buffer.append("\"></div>"); 277 278 if (pageContext.getRequest().getAttribute("zzz")==null) { 280 buffer.append("<script SRC=\""); 281 buffer.append(LayoutUtils.getSkin(pageContext.getSession()).getConfigDirectory(pageContext.getRequest())); 282 buffer.append("/scrollbar.js\"></script>"); 283 pageContext.getRequest().setAttribute("zzz", "zzz"); 284 } 285 286 buffer.append("<script>addLoadEvent(function() {initScrollbar(\""); 288 buffer.append(collectionTag.getStyleId()); 289 buffer.append("\",\"colLayer"); 290 buffer.append(lc_id); 291 buffer.append("\")});</script>"); 292 } 293 } 294 public void endFooter(StringBuffer in_buffer) { 295 in_buffer.append("</tr>\n"); 296 297 } 298 public void printFooterElement(StringBuffer in_buffer, String in_element, int in_span) { 299 in_buffer.append("<td "); 300 if (in_span>1) { 301 in_buffer.append(" colspan=\""); 302 in_buffer.append(in_span); 303 in_buffer.append("\""); 304 } 305 in_buffer.append(">"); 306 in_buffer.append(in_element); 307 in_buffer.append("</td>"); 308 309 } 310 public void startFooter(StringBuffer in_buffer) { 311 in_buffer.append("<tr>"); 312 } 313 314 316 319 public void endMathData(StringBuffer in_buffer) { 320 in_buffer.append("</tr>\n"); 321 } 322 323 public void renderMathData(StringBuffer in_buffer, String in_element, int in_span, String in_resultId, String in_styleClass) { 324 in_buffer.append("<td"); 325 if (in_styleClass!=null){ 326 in_buffer.append(" class=\""); 327 in_buffer.append(in_styleClass); 328 in_buffer.append("\""); 329 } 330 if (in_span>1){ 331 in_buffer.append(" colspan=\""); 332 in_buffer.append(in_span); 333 in_buffer.append("\""); 334 } 335 if (in_resultId!=null && in_resultId.length()!=0){ 336 in_buffer.append(" id=\"" + in_resultId + "\""); 337 } 338 in_buffer.append(">"); 339 in_buffer.append(in_element); 340 in_buffer.append("</td>\n"); 341 } 342 343 public void startMathData(StringBuffer in_buffer) { 344 in_buffer.append("<tr>\n"); 345 } 346 347 349 public void renderMultiLevelHeader(StringBuffer in_buffer, String in_title, String in_sortUrl, String in_styleClass, int in_colspan, int in_rowspan, String in_width) { 350 in_buffer.append("<th"); 351 if (in_colspan!=1) { 352 in_buffer.append(" colspan=\""); 353 in_buffer.append(in_colspan); 354 in_buffer.append("\""); 355 } 356 if (in_styleClass!=null) { 357 in_buffer.append(" class=\""); 358 in_buffer.append(in_styleClass); 359 in_buffer.append("\""); 360 } 361 if (in_rowspan!=1) { 362 in_buffer.append(" rowspan=\""); 363 in_buffer.append(in_rowspan); 364 in_buffer.append("\""); 365 } 366 if (in_width!=null) { 367 in_buffer.append(" width=\""); 368 in_buffer.append(in_width); 369 in_buffer.append("\""); 370 } 371 in_buffer.append(">"); 372 in_buffer.append(doPrintSortUrl(in_title, in_sortUrl)); 373 in_buffer.append("</th>"); 374 } 375 376 public void endMultiLevelHeaderRow(StringBuffer in_buffer) { 377 in_buffer.append("</tr>\n"); 378 } 379 public void startMultiLevelHeaderRow(StringBuffer in_buffer) { 380 in_buffer.append("<tr valign=\"top\" id=\"header\">"); 381 } 382 } | Popular Tags |