franta-hg@1
|
1 |
/* ================================================================
|
franta-hg@1
|
2 |
* Cewolf : Chart enabling Web Objects Framework
|
franta-hg@1
|
3 |
* ================================================================
|
franta-hg@1
|
4 |
*
|
franta-hg@1
|
5 |
* Project Info: http://cewolf.sourceforge.net
|
franta-hg@1
|
6 |
* Project Lead: Guido Laures (guido@laures.de);
|
franta-hg@1
|
7 |
*
|
franta-hg@1
|
8 |
* (C) Copyright 2002, by Guido Laures
|
franta-hg@1
|
9 |
*
|
franta-hg@1
|
10 |
* This library is free software; you can redistribute it and/or modify it under the terms
|
franta-hg@1
|
11 |
* of the GNU Lesser General Public License as published by the Free Software Foundation;
|
franta-hg@1
|
12 |
* either version 2.1 of
|
franta-hg@1
|
13 |
* the License, or (at your option) any later version.
|
franta-hg@1
|
14 |
*
|
franta-hg@1
|
15 |
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
franta-hg@1
|
16 |
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
franta-hg@1
|
17 |
* See the GNU Lesser General Public License for more details.
|
franta-hg@1
|
18 |
*
|
franta-hg@1
|
19 |
* You should have received a copy of the GNU Lesser General Public License along with this
|
franta-hg@1
|
20 |
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
franta-hg@1
|
21 |
* Boston, MA 02111-1307, USA.
|
franta-hg@1
|
22 |
*/
|
franta-hg@1
|
23 |
|
franta-hg@1
|
24 |
package de.laures.cewolf.taglib.html;
|
franta-hg@1
|
25 |
|
franta-hg@1
|
26 |
import java.io.IOException;
|
franta-hg@1
|
27 |
import java.io.Serializable;
|
franta-hg@1
|
28 |
import java.io.Writer;
|
franta-hg@1
|
29 |
|
franta-hg@1
|
30 |
import javax.servlet.jsp.JspException;
|
franta-hg@1
|
31 |
import javax.servlet.jsp.JspWriter;
|
franta-hg@1
|
32 |
|
franta-hg@1
|
33 |
import de.laures.cewolf.taglib.tags.CewolfBodyTag;
|
franta-hg@1
|
34 |
|
franta-hg@1
|
35 |
/**
|
franta-hg@1
|
36 |
* Abstract base class which holds attribbutes common for all HTML 4.0 tags.
|
franta-hg@1
|
37 |
* @author Guido Laures
|
franta-hg@1
|
38 |
*/
|
franta-hg@1
|
39 |
public abstract class AbstractHTMLBaseTag extends CewolfBodyTag implements Serializable{
|
franta-hg@1
|
40 |
|
franta-hg@1
|
41 |
protected static final int UNDEFINED_INT = -1;
|
franta-hg@1
|
42 |
protected static final float UNDEFINED_FLOAT = -1.0f;
|
franta-hg@1
|
43 |
protected static final String UNDEFINED_STR = null;
|
franta-hg@1
|
44 |
|
franta-hg@1
|
45 |
/** Holds value of property ID. */
|
franta-hg@1
|
46 |
protected String id = UNDEFINED_STR;
|
franta-hg@1
|
47 |
|
franta-hg@1
|
48 |
/** Holds value of property clazz. */
|
franta-hg@1
|
49 |
protected String clazz = UNDEFINED_STR;
|
franta-hg@1
|
50 |
|
franta-hg@1
|
51 |
/** Holds value of property style. */
|
franta-hg@1
|
52 |
protected String style = UNDEFINED_STR;
|
franta-hg@1
|
53 |
|
franta-hg@1
|
54 |
/** Holds value of property title. */
|
franta-hg@1
|
55 |
protected String title = UNDEFINED_STR;
|
franta-hg@1
|
56 |
|
franta-hg@1
|
57 |
/** Holds value of property lang. */
|
franta-hg@1
|
58 |
protected String lang = UNDEFINED_STR;
|
franta-hg@1
|
59 |
|
franta-hg@1
|
60 |
/** Holds value of property dir. */
|
franta-hg@1
|
61 |
protected String dir = UNDEFINED_STR;
|
franta-hg@1
|
62 |
|
franta-hg@1
|
63 |
/** Holds value of property onclick. */
|
franta-hg@1
|
64 |
protected String onclick = UNDEFINED_STR;
|
franta-hg@1
|
65 |
|
franta-hg@1
|
66 |
/** Holds value of property ondbclick. */
|
franta-hg@1
|
67 |
protected String ondbclick = UNDEFINED_STR;
|
franta-hg@1
|
68 |
|
franta-hg@1
|
69 |
/** Holds value of property onmousedown. */
|
franta-hg@1
|
70 |
protected String onmousedown = UNDEFINED_STR;
|
franta-hg@1
|
71 |
|
franta-hg@1
|
72 |
/** Holds value of property onmouseup. */
|
franta-hg@1
|
73 |
protected String onmouseup = UNDEFINED_STR;
|
franta-hg@1
|
74 |
|
franta-hg@1
|
75 |
/** Holds value of property onmouseover. */
|
franta-hg@1
|
76 |
protected String onmouseover = UNDEFINED_STR;
|
franta-hg@1
|
77 |
|
franta-hg@1
|
78 |
/** Holds value of property onmousemove. */
|
franta-hg@1
|
79 |
protected String onmousemove = UNDEFINED_STR;
|
franta-hg@1
|
80 |
|
franta-hg@1
|
81 |
/** Holds value of property onmouseout. */
|
franta-hg@1
|
82 |
protected String onmouseout = UNDEFINED_STR;
|
franta-hg@1
|
83 |
|
franta-hg@1
|
84 |
/** Holds value of property onkeypress. */
|
franta-hg@1
|
85 |
protected String onkeypress = UNDEFINED_STR;
|
franta-hg@1
|
86 |
|
franta-hg@1
|
87 |
/** Holds value of property onkeydown. */
|
franta-hg@1
|
88 |
protected String onkeydown = UNDEFINED_STR;
|
franta-hg@1
|
89 |
|
franta-hg@1
|
90 |
/** Holds value of property onkeyup. */
|
franta-hg@1
|
91 |
protected String onkeyup = UNDEFINED_STR;
|
franta-hg@1
|
92 |
|
franta-hg@1
|
93 |
public AbstractHTMLBaseTag(){
|
franta-hg@1
|
94 |
setId(UNDEFINED_STR);
|
franta-hg@1
|
95 |
}
|
franta-hg@1
|
96 |
|
franta-hg@1
|
97 |
protected abstract String getTagName();
|
franta-hg@1
|
98 |
|
franta-hg@1
|
99 |
protected abstract boolean hasBody();
|
franta-hg@1
|
100 |
|
franta-hg@1
|
101 |
protected abstract boolean wellFormed();
|
franta-hg@1
|
102 |
|
franta-hg@1
|
103 |
protected void reset(){
|
franta-hg@1
|
104 |
this.clazz = UNDEFINED_STR;
|
franta-hg@1
|
105 |
this.dir = UNDEFINED_STR;
|
franta-hg@1
|
106 |
this.id = UNDEFINED_STR;
|
franta-hg@1
|
107 |
this.lang = UNDEFINED_STR;
|
franta-hg@1
|
108 |
this.onclick = UNDEFINED_STR;
|
franta-hg@1
|
109 |
this.ondbclick = UNDEFINED_STR;
|
franta-hg@1
|
110 |
this.onkeydown = UNDEFINED_STR;
|
franta-hg@1
|
111 |
this.onkeypress = UNDEFINED_STR;
|
franta-hg@1
|
112 |
this.onkeyup = UNDEFINED_STR;
|
franta-hg@1
|
113 |
this.onmousedown = UNDEFINED_STR;
|
franta-hg@1
|
114 |
this.onmousemove = UNDEFINED_STR;
|
franta-hg@1
|
115 |
this.onmouseout = UNDEFINED_STR;
|
franta-hg@1
|
116 |
this.onmouseover = UNDEFINED_STR;
|
franta-hg@1
|
117 |
this.onmouseup = UNDEFINED_STR;
|
franta-hg@1
|
118 |
this.style = UNDEFINED_STR;
|
franta-hg@1
|
119 |
this.title = UNDEFINED_STR;
|
franta-hg@1
|
120 |
}
|
franta-hg@1
|
121 |
|
franta-hg@1
|
122 |
public int doStartTag() throws JspException {
|
franta-hg@1
|
123 |
JspWriter writer = pageContext.getOut();
|
franta-hg@1
|
124 |
try {
|
franta-hg@1
|
125 |
writer.write("<" + getTagName());
|
franta-hg@1
|
126 |
writeAttributes(writer);
|
franta-hg@1
|
127 |
if(hasBody()){
|
franta-hg@1
|
128 |
writer.write(">");
|
franta-hg@1
|
129 |
return EVAL_PAGE;
|
franta-hg@1
|
130 |
} else {
|
franta-hg@1
|
131 |
return SKIP_BODY;
|
franta-hg@1
|
132 |
}
|
franta-hg@1
|
133 |
} catch(IOException ioe){
|
franta-hg@1
|
134 |
super.pageContext.getServletContext().log("",ioe);
|
franta-hg@1
|
135 |
throw new JspException(ioe.getMessage());
|
franta-hg@1
|
136 |
}
|
franta-hg@1
|
137 |
}
|
franta-hg@1
|
138 |
|
franta-hg@1
|
139 |
public int doEndTag() throws JspException {
|
franta-hg@1
|
140 |
JspWriter writer = pageContext.getOut();
|
franta-hg@1
|
141 |
try{
|
franta-hg@1
|
142 |
if(hasBody()){
|
franta-hg@1
|
143 |
writer.write("</" + getTagName() + ">");
|
franta-hg@1
|
144 |
} else {
|
franta-hg@1
|
145 |
if(wellFormed()){
|
franta-hg@1
|
146 |
writer.write(" /");
|
franta-hg@1
|
147 |
}
|
franta-hg@1
|
148 |
writer.write(">");
|
franta-hg@1
|
149 |
}
|
franta-hg@1
|
150 |
return doAfterEndTag(EVAL_PAGE);
|
franta-hg@1
|
151 |
} catch(IOException ioe){
|
franta-hg@1
|
152 |
super.pageContext.getServletContext().log("",ioe);
|
franta-hg@1
|
153 |
throw new JspException(ioe.getMessage());
|
franta-hg@1
|
154 |
}
|
franta-hg@1
|
155 |
}
|
franta-hg@1
|
156 |
|
franta-hg@1
|
157 |
public void writeAttributes(Writer wr){
|
franta-hg@1
|
158 |
try {
|
franta-hg@1
|
159 |
appendAttributeDeclaration(wr, getId(), "ID");
|
franta-hg@1
|
160 |
appendAttributeDeclaration(wr, this.clazz, "CLASS");
|
franta-hg@1
|
161 |
appendAttributeDeclaration(wr, this.style, "STYLE");
|
franta-hg@1
|
162 |
appendAttributeDeclaration(wr, this.onclick, "ONCLICK");
|
franta-hg@1
|
163 |
appendAttributeDeclaration(wr, this.ondbclick, "ONDBCLICK");
|
franta-hg@1
|
164 |
appendAttributeDeclaration(wr, this.onkeydown, "ONKEYDOWN");
|
franta-hg@1
|
165 |
appendAttributeDeclaration(wr, this.onkeypress, "ONKEYPRESS");
|
franta-hg@1
|
166 |
appendAttributeDeclaration(wr, this.onkeyup, "ONKEYUP");
|
franta-hg@1
|
167 |
appendAttributeDeclaration(wr, this.onmousedown, "ONMOUSEDOWN");
|
franta-hg@1
|
168 |
appendAttributeDeclaration(wr, this.onmousemove, "ONMOUSEMOVE");
|
franta-hg@1
|
169 |
appendAttributeDeclaration(wr, this.onmouseout, "ONMOUSEOUT");
|
franta-hg@1
|
170 |
appendAttributeDeclaration(wr, this.onmouseover, "ONMOUSEOVER");
|
franta-hg@1
|
171 |
appendAttributeDeclaration(wr, this.onmouseup, "ONMOUSEUP");
|
franta-hg@1
|
172 |
appendAttributeDeclaration(wr, this.title, "TITLE");
|
franta-hg@1
|
173 |
appendAttributeDeclaration(wr, this.lang, "LANG");
|
franta-hg@1
|
174 |
appendAttributeDeclaration(wr, this.dir, "DIR");
|
franta-hg@1
|
175 |
} catch(IOException ioex){
|
franta-hg@1
|
176 |
ioex.printStackTrace();
|
franta-hg@1
|
177 |
}
|
franta-hg@1
|
178 |
}
|
franta-hg@1
|
179 |
|
franta-hg@1
|
180 |
protected void appendAttributeDeclaration(Writer wr, String attr, String name) throws IOException {
|
franta-hg@1
|
181 |
if(attr != UNDEFINED_STR){
|
franta-hg@1
|
182 |
wr.write(" " + name + "=\"" + attr + "\"");
|
franta-hg@1
|
183 |
}
|
franta-hg@1
|
184 |
}
|
franta-hg@1
|
185 |
|
franta-hg@1
|
186 |
protected void appendAttributeDeclaration(Writer wr, int attr, String name) throws IOException {
|
franta-hg@1
|
187 |
// does not call the according method for Strings to avoid additional
|
franta-hg@1
|
188 |
// String instantiation
|
franta-hg@1
|
189 |
if(attr != UNDEFINED_INT){
|
franta-hg@1
|
190 |
wr.write(" " + name + "=\"" + attr + "\"");
|
franta-hg@1
|
191 |
}
|
franta-hg@1
|
192 |
}
|
franta-hg@1
|
193 |
|
franta-hg@1
|
194 |
protected void appendAttributeDeclaration(Writer wr, float attr, String name) throws IOException {
|
franta-hg@1
|
195 |
// does not call the according method for Strings to avoid additional
|
franta-hg@1
|
196 |
// String instantiation
|
franta-hg@1
|
197 |
if(attr != UNDEFINED_FLOAT){
|
franta-hg@1
|
198 |
wr.write(" " + name + "=\"" + attr + "\"");
|
franta-hg@1
|
199 |
}
|
franta-hg@1
|
200 |
}
|
franta-hg@1
|
201 |
|
franta-hg@1
|
202 |
/** Setter for property clazz.
|
franta-hg@1
|
203 |
* @param clazz New value of property clazz.
|
franta-hg@1
|
204 |
*/
|
franta-hg@1
|
205 |
public void setClass(String clazz) {
|
franta-hg@1
|
206 |
this.clazz = clazz;
|
franta-hg@1
|
207 |
}
|
franta-hg@1
|
208 |
|
franta-hg@1
|
209 |
/** Setter for property style.
|
franta-hg@1
|
210 |
* @param style New value of property style.
|
franta-hg@1
|
211 |
*/
|
franta-hg@1
|
212 |
public void setStyle(String style) {
|
franta-hg@1
|
213 |
this.style = style;
|
franta-hg@1
|
214 |
}
|
franta-hg@1
|
215 |
|
franta-hg@1
|
216 |
/** Setter for property title.
|
franta-hg@1
|
217 |
* @param title New value of property title.
|
franta-hg@1
|
218 |
*/
|
franta-hg@1
|
219 |
public void setHtmltitle(String title) {
|
franta-hg@1
|
220 |
this.title = title;
|
franta-hg@1
|
221 |
}
|
franta-hg@1
|
222 |
|
franta-hg@1
|
223 |
/** Setter for property lang.
|
franta-hg@1
|
224 |
* @param lang New value of property lang.
|
franta-hg@1
|
225 |
*/
|
franta-hg@1
|
226 |
public void setLang(String lang) {
|
franta-hg@1
|
227 |
this.lang = lang;
|
franta-hg@1
|
228 |
}
|
franta-hg@1
|
229 |
|
franta-hg@1
|
230 |
/** Setter for property dir.
|
franta-hg@1
|
231 |
* @param dir New value of property dir.
|
franta-hg@1
|
232 |
*/
|
franta-hg@1
|
233 |
public void setDir(String dir) {
|
franta-hg@1
|
234 |
this.dir = dir;
|
franta-hg@1
|
235 |
}
|
franta-hg@1
|
236 |
|
franta-hg@1
|
237 |
/** Setter for property onclick.
|
franta-hg@1
|
238 |
* @param onclick New value of property onclick.
|
franta-hg@1
|
239 |
*/
|
franta-hg@1
|
240 |
public void setOnclick(String onclick) {
|
franta-hg@1
|
241 |
this.onclick = onclick;
|
franta-hg@1
|
242 |
}
|
franta-hg@1
|
243 |
|
franta-hg@1
|
244 |
/** Setter for property ondbclick.
|
franta-hg@1
|
245 |
* @param ondbclick New value of property ondbclick.
|
franta-hg@1
|
246 |
*/
|
franta-hg@1
|
247 |
public void setOndbclick(String ondbclick) {
|
franta-hg@1
|
248 |
this.ondbclick = ondbclick;
|
franta-hg@1
|
249 |
}
|
franta-hg@1
|
250 |
|
franta-hg@1
|
251 |
/** Setter for property onmousedown.
|
franta-hg@1
|
252 |
* @param onmousedown New value of property onmousedown.
|
franta-hg@1
|
253 |
*/
|
franta-hg@1
|
254 |
public void setOnmousedown(String onmousedown) {
|
franta-hg@1
|
255 |
this.onmousedown = onmousedown;
|
franta-hg@1
|
256 |
}
|
franta-hg@1
|
257 |
|
franta-hg@1
|
258 |
/** Setter for property onmouseup.
|
franta-hg@1
|
259 |
* @param onmouseup New value of property onmouseup.
|
franta-hg@1
|
260 |
*/
|
franta-hg@1
|
261 |
public void setOnmouseup(String onmouseup) {
|
franta-hg@1
|
262 |
this.onmouseup = onmouseup;
|
franta-hg@1
|
263 |
}
|
franta-hg@1
|
264 |
|
franta-hg@1
|
265 |
/** Setter for property onmouseover.
|
franta-hg@1
|
266 |
* @param onmouseover New value of property onmouseover.
|
franta-hg@1
|
267 |
*/
|
franta-hg@1
|
268 |
public void setOnmouseover(String onmouseover) {
|
franta-hg@1
|
269 |
this.onmouseover = onmouseover;
|
franta-hg@1
|
270 |
}
|
franta-hg@1
|
271 |
|
franta-hg@1
|
272 |
/** Setter for property onmousemove.
|
franta-hg@1
|
273 |
* @param onmousemove New value of property onmousemove.
|
franta-hg@1
|
274 |
*/
|
franta-hg@1
|
275 |
public void setOnmousemove(String onmousemove) {
|
franta-hg@1
|
276 |
this.onmousemove = onmousemove;
|
franta-hg@1
|
277 |
}
|
franta-hg@1
|
278 |
|
franta-hg@1
|
279 |
/** Setter for property onmouseout.
|
franta-hg@1
|
280 |
* @param onmouseout New value of property onmouseout.
|
franta-hg@1
|
281 |
*/
|
franta-hg@1
|
282 |
public void setOnmouseout(String onmouseout) {
|
franta-hg@1
|
283 |
this.onmouseout = onmouseout;
|
franta-hg@1
|
284 |
}
|
franta-hg@1
|
285 |
|
franta-hg@1
|
286 |
/** Setter for property onkeypress.
|
franta-hg@1
|
287 |
* @param onkeypress New value of property onkeypress.
|
franta-hg@1
|
288 |
*/
|
franta-hg@1
|
289 |
public void setOnkeypress(String onkeypress) {
|
franta-hg@1
|
290 |
this.onkeypress = onkeypress;
|
franta-hg@1
|
291 |
}
|
franta-hg@1
|
292 |
|
franta-hg@1
|
293 |
/** Setter for property onkeydown.
|
franta-hg@1
|
294 |
* @param onkeydown New value of property onkeydown.
|
franta-hg@1
|
295 |
*/
|
franta-hg@1
|
296 |
public void setOnkeydown(String onkeydown) {
|
franta-hg@1
|
297 |
this.onkeydown = onkeydown;
|
franta-hg@1
|
298 |
}
|
franta-hg@1
|
299 |
|
franta-hg@1
|
300 |
/** Setter for property onkeyup.
|
franta-hg@1
|
301 |
* @param onkeyup New value of property onkeyup.
|
franta-hg@1
|
302 |
*/
|
franta-hg@1
|
303 |
public void setOnkeyup(String onkeyup) {
|
franta-hg@1
|
304 |
this.onkeyup = onkeyup;
|
franta-hg@1
|
305 |
}
|
franta-hg@1
|
306 |
|
franta-hg@1
|
307 |
}
|