Source code: org/apache/webapp/admin/RowTag.java
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;
22 import java.net.URLEncoder;
23 import java.util.ArrayList;
24 import javax.servlet.http.HttpServletResponse;
25 import javax.servlet.jsp.JspException;
26 import javax.servlet.jsp.JspWriter;
27 import javax.servlet.jsp.PageContext;
28 import javax.servlet.jsp.tagext.BodyTagSupport;
29 import javax.servlet.jsp.tagext.Tag;
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: 302726 $ $Date: 2004-02-27 09:59:07 -0500 (Fri, 27 Feb 2004) $
49 */
50
51 public class RowTag extends BodyTagSupport {
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 label = null;
70
71 public void setLabel(String label) {
72 this.label = label;
73 }
74
75
76 /**
77 * The data of the table data element of this row.
78 */
79 protected String data = null;
80
81 public void setData(String data) {
82 this.data = data;
83 }
84
85 /**
86 * The style of the label.
87 */
88 protected String labelStyle = null;
89
90 public String getLabelStyle() {
91 return (this.labelStyle);
92 }
93
94 public void setLabelStyle(String labelStyle) {
95 this.labelStyle = labelStyle;
96 }
97
98
99 /**
100 * The style of the data.
101 */
102 protected String dataStyle = null;
103
104 public String getdataStyle() {
105 return (this.dataStyle);
106 }
107
108 public void setdataStyle(String dataStyle) {
109 this.dataStyle = dataStyle;
110 }
111
112 /**
113 * The styleId for the label.
114 */
115 protected String styleId = null;
116
117 public String getStyleId() {
118 return (this.styleId);
119 }
120
121 public void setStyleId(String 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 {
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 {
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 {
160
161 // Find our parent TableTag instance
162 Tag parent = getParent();
163 while ((parent != null) && !(parent instanceof TableTag)) {
164 parent = parent.getParent();
165 }
166 if (parent == null) {
167 throw new JspException("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 response =
174 (HttpServletResponse) 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 }