KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webapp > admin > RowTag


1 /*
2  * Copyright 2001,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17
18 package org.apache.webapp.admin;
19
20
21 import java.io.IOException JavaDoc;
22 import java.net.URLEncoder JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import javax.servlet.http.HttpServletResponse JavaDoc;
25 import javax.servlet.jsp.JspException JavaDoc;
26 import javax.servlet.jsp.JspWriter JavaDoc;
27 import javax.servlet.jsp.PageContext JavaDoc;
28 import javax.servlet.jsp.tagext.BodyTagSupport JavaDoc;
29 import javax.servlet.jsp.tagext.Tag JavaDoc;
30
31
32 /**
33  * <p>Nested tag that represents an individual "instant table". This tag
34  * is valid <strong>only</strong> when nested within an TableTag tag.
35  * This tag has the following user-settable attributes:</p>
36  * <ul>
37  * <li><strong>header</strong> - Is this a header row?</li>
38  * <li><strong>label</strong> - label to be displayed.</li>
39  * <li><strong>data</strong> - data of the table data element.</li>
40  * <li><strong>labelStyle</strong> - Style to be applied to the
41  * label table data element.</li>
42  * <li><strong>dataStyle</strong> - Style to be applied to the data table
43  * data element.</li>
44  *
45  * </ul>
46  *
47  * @author Manveen Kaur
48  * @version $Revision: 1.3 $ $Date: 2004/02/27 14:59:01 $
49  */

50
51 public class RowTag extends BodyTagSupport JavaDoc {
52     
53     /**
54      * Is this the header row?
55      */

56     protected boolean header = false;
57     
58     public boolean getHeader() {
59         return (this.header);
60     }
61     
62     public void setHeader(boolean header) {
63         this.header = header;
64     }
65     
66     /**
67      * The label that will be rendered for this row's table data element.
68      */

69     protected String JavaDoc label = null;
70    
71     public void setLabel(String JavaDoc label) {
72         this.label = label;
73     }
74     
75     
76     /**
77      * The data of the table data element of this row.
78      */

79     protected String JavaDoc data = null;
80     
81     public void setData(String JavaDoc data) {
82         this.data = data;
83     }
84     
85     /**
86      * The style of the label.
87      */

88     protected String JavaDoc labelStyle = null;
89     
90     public String JavaDoc getLabelStyle() {
91         return (this.labelStyle);
92     }
93     
94     public void setLabelStyle(String JavaDoc labelStyle) {
95         this.labelStyle = labelStyle;
96     }
97     
98     
99     /**
100      * The style of the data.
101      */

102     protected String JavaDoc dataStyle = null;
103     
104     public String JavaDoc getdataStyle() {
105         return (this.dataStyle);
106     }
107     
108     public void setdataStyle(String JavaDoc dataStyle) {
109         this.dataStyle = dataStyle;
110     }
111  
112     /**
113      * The styleId for the label.
114      */

115     protected String JavaDoc styleId = null;
116     
117     public String JavaDoc getStyleId() {
118         return (this.styleId);
119     }
120     
121     public void setStyleId(String JavaDoc styleId) {
122         this.styleId = styleId;
123     }
124     
125         
126     // --------------------------------------------------------- Public Methods
127

128     
129     /**
130      * Process the start of this tag.
131      *
132      * @exception JspException if a JSP exception has occurred
133      */

134     public int doStartTag() throws JspException JavaDoc {
135         
136          // Do no further processing for now
137
return (EVAL_BODY_TAG);
138         
139     }
140     
141     
142     /**
143      * Process the body text of this tag (if any).
144      *
145      * @exception JspException if a JSP exception has occurred
146      */

147     public int doAfterBody() throws JspException JavaDoc {
148        
149         return (SKIP_BODY);
150         
151     }
152     
153     
154     /**
155      * Record this action with our surrounding ActionsTag instance.
156      *
157      * @exception JspException if a processing error occurs
158      */

159     public int doEndTag() throws JspException JavaDoc {
160         
161         // Find our parent TableTag instance
162
Tag JavaDoc parent = getParent();
163         while ((parent != null) && !(parent instanceof TableTag)) {
164             parent = parent.getParent();
165         }
166         if (parent == null) {
167             throw new JspException JavaDoc("Must be nested in a TableTag instance");
168         }
169         TableTag table = (TableTag) parent;
170         
171         // Register the information for the row represented by
172
// this row
173
HttpServletResponse JavaDoc response =
174         (HttpServletResponse JavaDoc) pageContext.getResponse();
175         table.addRow(header, label, data, labelStyle, dataStyle, styleId);
176         
177         return (EVAL_PAGE);
178         
179     }
180     
181     
182     /**
183      * Release all state information set by this tag.
184      */

185     public void release() {
186         
187         //super.release();
188

189         this.header= false;
190         this.label = null;
191         this.data = null;
192         this.labelStyle = null;
193         this.dataStyle = null;
194         this.styleId = null;
195         
196     }
197     
198     
199 }
200
Popular Tags