KickJava   Java API By Example, From Geeks To Geeks.

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


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 "data" for a row. This tag
34  * is valid <strong>only</strong> when nested within a RowTag tag.
35  *
36  * <p>In addition, the body content of this tag is used as the user-visible
37  * data for the action, so that it may be conveniently localized.</p>
38  *
39  * <strong>FIXME</strong> - Internationalize the exception messages!
40  *
41  * @author Manveen Kaur
42  * @version $Revision: 1.2 $
43  */

44
45 public class DataTag extends BodyTagSupport JavaDoc {
46
47
48     // ----------------------------------------------------- Instance Variables
49

50
51     /**
52      * The data that will be rendered for this table row.
53      */

54     protected String JavaDoc data = null;
55
56
57     // --------------------------------------------------------- Public Methods
58

59
60     /**
61      * Process the start of this tag.
62      *
63      * @exception JspException if a JSP exception has occurred
64      */

65     public int doStartTag() throws JspException JavaDoc {
66
67         // Initialize the holder for our data text
68
this.data = null;
69
70         // Do no further processing for now
71
return (EVAL_BODY_TAG);
72
73     }
74
75
76     /**
77      * Process the body text of this tag (if any).
78      *
79      * @exception JspException if a JSP exception has occurred
80      */

81     public int doAfterBody() throws JspException JavaDoc {
82
83         String JavaDoc data = bodyContent.getString();
84         if (data != null) {
85             data = data.trim();
86             if (data.length() > 0)
87                 this.data = data;
88         }
89         return (SKIP_BODY);
90
91     }
92
93
94     /**
95      * Record this action with our surrounding ActionsTag instance.
96      *
97      * @exception JspException if a processing error occurs
98      */

99     public int doEndTag() throws JspException JavaDoc {
100
101         // Find our parent ActionsTag instance
102
Tag JavaDoc parent = getParent();
103         if ((parent == null) || !(parent instanceof RowTag))
104             throw new JspException JavaDoc("Must be nested in a rowTag isntance");
105         RowTag row = (RowTag) parent;
106
107         // Register the information for the action represented by
108
// this action
109
HttpServletResponse JavaDoc response =
110             (HttpServletResponse JavaDoc) pageContext.getResponse();
111         row.setData(data);
112         
113         return (EVAL_PAGE);
114
115     }
116
117
118     /**
119      * Release all state information set by this tag.
120      */

121     public void release() {
122
123         this.data = null;
124     }
125
126
127 }
128
Popular Tags