KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > taglib > GridRowTag


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * Initial developer(s): Michel-Ange ANTON
22  * --------------------------------------------------------------------------
23  * $Id: GridRowTag.java,v 1.3 2003/06/20 17:15:42 antonma Exp $
24  * --------------------------------------------------------------------------
25  */

26
27 package org.objectweb.jonas.webapp.taglib;
28
29 import javax.servlet.jsp.tagext.Tag JavaDoc;
30
31 public class GridRowTag extends GridTableBaseTag {
32
33 // ----------------------------------------------------- Properties
34

35     private boolean changeStyle = false;
36
37     public boolean isChangeStyle() {
38         return changeStyle;
39     }
40
41     public void setChangeStyle(boolean changeStyle) {
42         this.changeStyle = changeStyle;
43     }
44
45 // ----------------------------------------------------- Public Methods
46

47     /**
48      * Release resources after Tag processing has finished.
49      */

50     public void release() {
51         super.release();
52         changeStyle = false;
53     }
54
55 // ----------------------------------------------------- Protected Methods
56

57     /**
58      * Return the HTML element.
59      */

60     protected String JavaDoc getHtmlElement() {
61         return "tr";
62     }
63
64     /**
65      * Duplicate of <code>BaseHandlerTag.prepareStyles()" method.
66      * Add the alternate class (odd or even) with .
67      *
68      * @return The prepared String for inclusion in the HTML tag.
69      */

70     protected String JavaDoc prepareStyles() {
71         StringBuffer JavaDoc styles = new StringBuffer JavaDoc();
72         if (getStyle() != null) {
73             styles.append(" style=\"");
74             styles.append(getStyle());
75             styles.append("\"");
76         }
77
78         // Get the row class from the GridTag parent
79
String JavaDoc sClass = getStyleClass();
80         if (sClass == null) {
81             sClass = getRowClass();
82         }
83         // Render class
84
if (sClass != null) {
85             styles.append(" class=\"");
86             styles.append(sClass);
87             styles.append("\"");
88         }
89
90         if (getStyleId() != null) {
91             styles.append(" id=\"");
92             styles.append(getStyleId());
93             styles.append("\"");
94         }
95         if (getTitle() != null) {
96             styles.append(" title=\"");
97             styles.append(getTitle());
98             styles.append("\"");
99         }
100         return styles.toString();
101     }
102
103     /**
104      * Determine the Row Class from the GridTag.
105      */

106     protected String JavaDoc getRowClass() {
107         // Determine if embedded in an GridTag
108
Tag JavaDoc tag = findAncestorWithClass(this, GridTag.class);
109         if (tag == null) {
110             return null;
111         }
112         // Determine the current row number
113
GridTag oTag = (GridTag) tag;
114         return oTag.getRowStyle(changeStyle);
115     }
116
117 }
Popular Tags