KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > displaytag > tags > el > ELColumnTag


1 /**
2  * Licensed under the Artistic License; you may not use this file
3  * except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  * http://displaytag.sourceforge.net/license.html
7  *
8  * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
9  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
10  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11  */

12 package org.displaytag.tags.el;
13
14 import javax.servlet.jsp.JspException JavaDoc;
15
16
17 /**
18  * Adds EL support to ColumnTag.
19  * @author Tim McCune
20  * @author Fabrizio Giustina
21  * @version $Revision: 1007 $ ($Author: fgiust $)
22  */

23 public class ELColumnTag extends org.displaytag.tags.ColumnTag
24 {
25
26     /**
27      * D1597A17A6.
28      */

29     private static final long serialVersionUID = 899149338534L;
30
31     /**
32      * Expression for the "autoLink" tag attribute.
33      */

34     private String JavaDoc autoLinkExpr;
35
36     /**
37      * Expression for the "escapeXml" tag attribute.
38      */

39     private String JavaDoc escapeXmlExpr;
40
41     /**
42      * Expression for the "format" tag attribute.
43      */

44     private String JavaDoc formatExpr;
45
46     /**
47      * Expression for the "class" tag attribute.
48      */

49     private String JavaDoc classExpr;
50
51     /**
52      * Expression for the "decorator" tag attribute.
53      */

54     private String JavaDoc decoratorExpr;
55
56     /**
57      * Expression for the "group" tag attribute.
58      */

59     private String JavaDoc groupExpr;
60
61     /**
62      * Expression for the "headerClass" tag attribute.
63      */

64     private String JavaDoc headerClassExpr;
65
66     /**
67      * Expression for the "href" tag attribute.
68      */

69     private String JavaDoc hrefExpr;
70
71     /**
72      * Expression for the "maxLength" tag attribute.
73      */

74     private String JavaDoc maxLengthExpr;
75
76     /**
77      * Expression for the "maxWords" tag attribute.
78      */

79     private String JavaDoc maxWordsExpr;
80
81     /**
82      * Expression for the "media" tag attribute.
83      */

84     private String JavaDoc mediaExpr;
85
86     /**
87      * Expression for the "nulls" tag attribute.
88      */

89     private String JavaDoc nullsExpr;
90
91     /**
92      * Expression for the "paramId" tag attribute.
93      */

94     private String JavaDoc paramIdExpr;
95
96     /**
97      * Expression for the "paramName" tag attribute.
98      */

99     private String JavaDoc paramNameExpr;
100
101     /**
102      * Expression for the "paramProperty" tag attribute.
103      */

104     private String JavaDoc paramPropertyExpr;
105
106     /**
107      * Expression for the "paramScope" tag attribute.
108      */

109     private String JavaDoc paramScopeExpr;
110
111     /**
112      * Expression for the "property" tag attribute.
113      */

114     private String JavaDoc propertyExpr;
115
116     /**
117      * Expression for the "title" tag attribute.
118      */

119     private String JavaDoc titleExpr;
120
121     /**
122      * Expression for the "style" tag attribute.
123      */

124     private String JavaDoc styleExpr;
125
126     /**
127      * Expression for the "url" tag attribute.
128      */

129     private String JavaDoc urlExpr;
130
131     /**
132      * Expression for the "titleKey" tag attribute.
133      */

134     private String JavaDoc titleKeyExpr;
135
136     /**
137      * Expression for the "sortable" tag attribute.
138      */

139     private String JavaDoc sortableExpr;
140
141     /**
142      * Expression for the "sortName" tag attribute.
143      */

144     private String JavaDoc sortNameExpr;
145
146     /**
147      * Expression for the "sortProperty" tag attribute.
148      */

149     private String JavaDoc sortPropertyExpr;
150
151     /**
152      * Expression for the "defaultorder" tag attribute.
153      */

154     private String JavaDoc defaultorderExpr;
155
156     /**
157      * Expression for the "scope" tag attribute.
158      */

159     private String JavaDoc scopeExpr;
160
161     /**
162      * Expression for the "headerScope" tag attribute.
163      */

164     private String JavaDoc headerScopeExpr;
165
166     /**
167      * Expression for the "value" tag attribute.
168      */

169     private String JavaDoc valueExpr;
170
171     /**
172      * Expression for the "comparator" tag attribute.
173      */

174     private String JavaDoc comparatorExpr;
175
176     /**
177      * @see org.displaytag.tags.ColumnTag#setComparator(Object)
178      * @param value EL expression for attribute value
179      */

180     public void setComparator(String JavaDoc value)
181     {
182         comparatorExpr = value;
183     }
184
185     /**
186      * @see org.displaytag.tags.ColumnTag#setAutolink(boolean)
187      * @param value EL expression for attribute value
188      */

189     public void setAutolink(String JavaDoc value)
190     {
191         autoLinkExpr = value;
192     }
193
194     /**
195      * @see org.displaytag.tags.ColumnTag#setSortProperty(java.lang.String)
196      * @param value EL expression for attribute value
197      */

198     public void setSortProperty(String JavaDoc value)
199     {
200         this.sortPropertyExpr = value;
201     }
202
203     /**
204      * @see org.displaytag.tags.ColumnTag#setClass(java.lang.String)
205      * @param value EL expression for attribute value
206      */

207     public void setClass(String JavaDoc value)
208     {
209         classExpr = value;
210     }
211
212     /**
213      * @see org.displaytag.tags.ColumnTag#setFormat(java.lang.String)
214      * @param value EL expression for attribute value
215      */

216     public void setFormat(String JavaDoc value)
217     {
218         formatExpr = value;
219     }
220
221     /**
222      * @see org.displaytag.tags.ColumnTag#setDecorator(java.lang.String)
223      * @param value EL expression for attribute value
224      */

225     public void setDecorator(String JavaDoc value)
226     {
227         decoratorExpr = value;
228     }
229
230     /**
231      * @see org.displaytag.tags.ColumnTag#setGroup(int)
232      * @param value EL expression for attribute value
233      */

234     public void setGroup(String JavaDoc value)
235     {
236         groupExpr = value;
237     }
238
239     /**
240      * @see org.displaytag.tags.ColumnTag#setHeaderClass(java.lang.String)
241      * @param value EL expression for attribute value
242      */

243     public void setHeaderClass(String JavaDoc value)
244     {
245         headerClassExpr = value;
246     }
247
248     /**
249      * @see org.displaytag.tags.ColumnTag#setHref(java.lang.String)
250      * @param value EL expression for attribute value
251      */

252     public void setHref(String JavaDoc value)
253     {
254         hrefExpr = value;
255     }
256
257     /**
258      * @see org.displaytag.tags.ColumnTag#setMaxLength(int)
259      * @param value EL expression for attribute value
260      */

261     public void setMaxLength(String JavaDoc value)
262     {
263         maxLengthExpr = value;
264     }
265
266     /**
267      * @see org.displaytag.tags.ColumnTag#setMaxWords(int)
268      * @param value EL expression for attribute value
269      */

270     public void setMaxWords(String JavaDoc value)
271     {
272         maxWordsExpr = value;
273     }
274
275     /**
276      * @see org.displaytag.tags.ColumnTag#setMedia(java.lang.String)
277      * @param value EL expression for attribute value
278      */

279     public void setMedia(String JavaDoc value)
280     {
281         mediaExpr = value;
282     }
283
284     /**
285      * @see org.displaytag.tags.ColumnTag#setNulls(boolean)
286      * @param value EL expression for attribute value
287      */

288     public void setNulls(String JavaDoc value)
289     {
290         nullsExpr = value;
291     }
292
293     /**
294      * @see org.displaytag.tags.ColumnTag#setParamId(java.lang.String)
295      * @param value EL expression for attribute value
296      */

297     public void setParamId(String JavaDoc value)
298     {
299         paramIdExpr = value;
300     }
301
302     /**
303      * @see org.displaytag.tags.ColumnTag#setParamName(java.lang.String)
304      * @param value EL expression for attribute value
305      */

306     public void setParamName(String JavaDoc value)
307     {
308         paramNameExpr = value;
309     }
310
311     /**
312      * @see org.displaytag.tags.ColumnTag#setParamProperty(java.lang.String)
313      * @param value EL expression for attribute value
314      */

315     public void setParamProperty(String JavaDoc value)
316     {
317         paramPropertyExpr = value;
318     }
319
320     /**
321      * @see org.displaytag.tags.ColumnTag#setParamScope(java.lang.String)
322      * @param value EL expression for attribute value
323      */

324     public void setParamScope(String JavaDoc value)
325     {
326         paramScopeExpr = value;
327     }
328
329     /**
330      * @see org.displaytag.tags.ColumnTag#setProperty(java.lang.String)
331      * @param value EL expression for attribute value
332      */

333     public void setProperty(String JavaDoc value)
334     {
335         propertyExpr = value;
336     }
337
338     /**
339      * @see org.displaytag.tags.ColumnTag#setSortable(boolean)
340      * @param value EL expression for attribute value
341      */

342     public void setSortable(String JavaDoc value)
343     {
344         sortableExpr = value;
345     }
346
347     /**
348      * @param value EL expression for attribute value
349      * @see org.displaytag.tags.ColumnTag#setSortName(java.lang.String)
350      */

351     public void setSortName(String JavaDoc value)
352     {
353         sortNameExpr = value;
354     }
355
356     /**
357      * @see org.displaytag.tags.ColumnTag#setTitle(java.lang.String)
358      * @param value EL expression for attribute value
359      */

360     public void setTitle(String JavaDoc value)
361     {
362         titleExpr = value;
363     }
364
365     /**
366      * @see org.displaytag.tags.ColumnTag#setStyle(java.lang.String)
367      * @param value EL expression for attribute value
368      */

369     public void setStyle(String JavaDoc value)
370     {
371         styleExpr = value;
372     }
373
374     /**
375      * @see org.displaytag.tags.ColumnTag#setTitleKey(java.lang.String)
376      * @param value EL expression for attribute value
377      */

378     public void setTitleKey(String JavaDoc value)
379     {
380         titleKeyExpr = value;
381     }
382
383     /**
384      * @see org.displaytag.tags.ColumnTag#setUrl(java.lang.String)
385      * @param value EL expression for attribute value
386      */

387     public void setUrl(String JavaDoc value)
388     {
389         urlExpr = value;
390     }
391
392     /**
393      * @see org.displaytag.tags.TableTag#setDefaultorder(java.lang.String)
394      * @param value EL expression for attribute value
395      */

396     public void setDefaultorder(String JavaDoc value)
397     {
398         defaultorderExpr = value;
399     }
400
401     /**
402      * @see org.displaytag.tags.ColumnTag#setScope(java.lang.String)
403      * @param value EL expression for attribute value
404      */

405     public void setScope(String JavaDoc value)
406     {
407         scopeExpr = value;
408     }
409
410     /**
411      * @see org.displaytag.tags.ColumnTag#setHeaderScope(java.lang.String)
412      * @param value EL expression for attribute value
413      */

414     public void setHeaderScope(String JavaDoc value)
415     {
416         headerScopeExpr = value;
417     }
418
419     /**
420      * @see org.displaytag.tags.ColumnTag#setValue(java.lang.Object)
421      * @param value EL expression for attribute value
422      */

423     public void setValue(String JavaDoc value)
424     {
425         this.valueExpr = value;
426     }
427
428     /**
429      * @see javax.servlet.jsp.tagext.Tag#doStartTag()
430      */

431     public int doStartTag() throws JspException JavaDoc
432     {
433         evaluateExpressions();
434
435         return super.doStartTag();
436     }
437
438     /**
439      * Evaluates the expressions for all the given attributes and pass results up to the parent tag.
440      * @throws JspException for exceptions occurred during evaluation.
441      */

442     private void evaluateExpressions() throws JspException JavaDoc
443     {
444         ExpressionEvaluator eval = new ExpressionEvaluator(this, pageContext);
445
446         if (autoLinkExpr != null)
447         {
448             super.setAutolink(eval.evalBoolean("autolink", autoLinkExpr)); //$NON-NLS-1$
449
}
450         if (escapeXmlExpr != null)
451         {
452             super.setEscapeXml(eval.evalBoolean("escapeXml", escapeXmlExpr)); //$NON-NLS-1$
453
}
454         if (formatExpr != null)
455         {
456             super.setFormat(eval.evalString("format", formatExpr)); //$NON-NLS-1$
457
}
458         if (classExpr != null)
459         {
460             super.setClass(eval.evalString("class", classExpr)); //$NON-NLS-1$
461
}
462         if (decoratorExpr != null)
463         {
464             super.setDecorator(eval.evalString("decorator", decoratorExpr)); //$NON-NLS-1$
465
}
466         if (groupExpr != null)
467         {
468             super.setGroup(eval.evalInt("group", groupExpr)); //$NON-NLS-1$
469
}
470         if (headerClassExpr != null)
471         {
472             super.setHeaderClass(eval.evalString("headerClass", headerClassExpr)); //$NON-NLS-1$
473
}
474         if (hrefExpr != null)
475         {
476             super.setHref(eval.evalString("href", hrefExpr)); //$NON-NLS-1$
477
}
478         if (maxLengthExpr != null)
479         {
480             super.setMaxLength(eval.evalInt("maxLength", maxLengthExpr)); //$NON-NLS-1$
481
}
482         if (maxWordsExpr != null)
483         {
484             super.setMaxWords(eval.evalInt("maxWords", maxWordsExpr)); //$NON-NLS-1$
485
}
486         if (mediaExpr != null)
487         {
488             super.setMedia(eval.evalString("media", mediaExpr)); //$NON-NLS-1$
489
}
490         if (nullsExpr != null)
491         {
492             super.setNulls(eval.evalBoolean("nulls", nullsExpr)); //$NON-NLS-1$
493
}
494         if (paramIdExpr != null)
495         {
496             super.setParamId(eval.evalString("paramId", paramIdExpr)); //$NON-NLS-1$
497
}
498         if (paramNameExpr != null)
499         {
500             // todo should be handled the same way the "name" table attribute is handled, no double evaluation
501
super.setParamName(eval.evalString("paramName", paramNameExpr)); //$NON-NLS-1$
502
}
503         if (paramPropertyExpr != null)
504         {
505             super.setParamProperty(eval.evalString("paramProperty", paramPropertyExpr)); //$NON-NLS-1$
506
}
507         if (paramScopeExpr != null)
508         {
509             super.setParamScope(eval.evalString("paramScope", paramScopeExpr)); //$NON-NLS-1$
510
}
511         if (sortableExpr != null)
512         {
513             super.setSortable(eval.evalBoolean("sortable", sortableExpr)); //$NON-NLS-1$
514
}
515         if (sortNameExpr != null)
516         {
517             super.setSortName(eval.evalString("sortName", sortNameExpr)); //$NON-NLS-1$
518
}
519         if (styleExpr != null)
520         {
521             super.setStyle(eval.evalString("style", styleExpr)); //$NON-NLS-1$
522
}
523         if (urlExpr != null)
524         {
525             super.setUrl(eval.evalString("url", urlExpr)); //$NON-NLS-1$
526
}
527         if (propertyExpr != null)
528         {
529             String JavaDoc property = eval.evalString("property", propertyExpr); //$NON-NLS-1$
530
super.setProperty(property);
531         }
532         if (titleExpr != null)
533         {
534             String JavaDoc title = eval.evalString("title", titleExpr); //$NON-NLS-1$
535
super.setTitle(title);
536         }
537         if (titleKeyExpr != null)
538         {
539             super.setTitleKey(eval.evalString("titleKey", titleKeyExpr)); //$NON-NLS-1$
540
}
541         if (sortPropertyExpr != null)
542         {
543             super.setSortProperty(eval.evalString("sortProperty", sortPropertyExpr)); //$NON-NLS-1$
544
}
545         if (defaultorderExpr != null)
546         {
547             super.setDefaultorder(eval.evalString("defaultorder", defaultorderExpr)); //$NON-NLS-1$
548
}
549         if (scopeExpr != null)
550         {
551             super.setScope(eval.evalString("scope", scopeExpr)); //$NON-NLS-1$
552
}
553         if (headerScopeExpr != null)
554         {
555             super.setHeaderScope(eval.evalString("headerScope", headerScopeExpr)); //$NON-NLS-1$
556
}
557         if (valueExpr != null)
558         {
559             super.setValue(eval.eval("value", valueExpr, Object JavaDoc.class)); //$NON-NLS-1$
560
}
561         if (comparatorExpr != null)
562         {
563             super.setValue(eval.eval("comparator", comparatorExpr, Object JavaDoc.class)); //$NON-NLS-1$
564
}
565
566     }
567
568     /**
569      * @see javax.servlet.jsp.tagext.Tag#release()
570      */

571     public void release()
572     {
573         super.release();
574         this.autoLinkExpr = null;
575         this.classExpr = null;
576         this.decoratorExpr = null;
577         this.groupExpr = null;
578         this.headerClassExpr = null;
579         this.hrefExpr = null;
580         this.maxLengthExpr = null;
581         this.maxWordsExpr = null;
582         this.mediaExpr = null;
583         this.nullsExpr = null;
584         this.paramIdExpr = null;
585         this.paramNameExpr = null;
586         this.paramPropertyExpr = null;
587         this.paramScopeExpr = null;
588         this.propertyExpr = null;
589         this.sortableExpr = null;
590         this.styleExpr = null;
591         this.titleExpr = null;
592         this.titleKeyExpr = null;
593         this.urlExpr = null;
594         this.sortPropertyExpr = null;
595         this.defaultorderExpr = null;
596         this.scopeExpr = null;
597         this.headerScopeExpr = null;
598         this.formatExpr = null;
599         this.escapeXmlExpr = null;
600         this.valueExpr = null;
601     }
602
603 }
Popular Tags