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;
15
16 import org.displaytag.tags.CaptionTag;
17
18
19 /**
20 * Adds EL support to CaptionTag.
21 * @author Fabrizio Giustina
22 * @version $Revision: 1081 $ ($Author: fgiust $)
23 */
24 public class ELCaptionTag extends CaptionTag
25 {
26
27 /**
28 * D1597A17A6.
29 */
30 private static final long serialVersionUID = 899149338534L;
31
32 /**
33 * Expression for the "class" tag attribute.
34 */
35 private String classExpr;
36
37 /**
38 * Expression for the "dir" tag attribute.
39 */
40 private String dirExpr;
41
42 /**
43 * Expression for the "id" tag attribute.
44 */
45 private String idExpr;
46
47 /**
48 * Expression for the "lang" tag attribute.
49 */
50 private String langExpr;
51
52 /**
53 * Expression for the "media" tag attribute.
54 */
55 private String mediaExpr;
56
57 /**
58 * Expression for the "style" tag attribute.
59 */
60 private String styleExpr;
61
62 /**
63 * Expression for the "title" tag attribute.
64 */
65 private String titleExpr;
66
67 /**
68 * @see org.displaytag.tags.CaptionTag#setClass(java.lang.String)
69 */
70 public void setClass(String value)
71 {
72 classExpr = value;
73 }
74
75 /**
76 * @see org.displaytag.tags.CaptionTag#setDir(java.lang.String)
77 */
78 public void setDir(String value)
79 {
80 dirExpr = value;
81 }
82
83 /**
84 * @see javax.servlet.jsp.tagext.TagSupport#setId(java.lang.String)
85 */
86 public void setId(String value)
87 {
88 idExpr = value;
89 }
90
91 /**
92 * @see org.displaytag.tags.CaptionTag#setLang(java.lang.String)
93 */
94 public void setLang(String value)
95 {
96 langExpr = value;
97 }
98
99 /**
100 * @see org.displaytag.tags.CaptionTag#setMedia(java.lang.String)
101 * @param value EL expression for attribute value
102 */
103 public void setMedia(String value)
104 {
105 mediaExpr = value;
106 }
107
108 /**
109 * @see org.displaytag.tags.CaptionTag#setStyle(java.lang.String)
110 */
111 public void setStyle(String value)
112 {
113 styleExpr = value;
114 }
115
116 /**
117 * @see org.displaytag.tags.CaptionTag#setTitle(java.lang.String)
118 */
119 public void setTitle(String value)
120 {
121 titleExpr = value;
122 }
123
124 /**
125 * @see javax.servlet.jsp.tagext.Tag#doStartTag()
126 */
127 public int doStartTag() throws JspException
128 {
129 evaluateExpressions();
130 return super.doStartTag();
131 }
132
133 /**
134 * Evaluates the expressions for all the given attributes and pass results up to the parent tag.
135 * @throws JspException for exceptions occurred during evaluation.
136 */
137 private void evaluateExpressions() throws JspException
138 {
139 ExpressionEvaluator eval = new ExpressionEvaluator(this, pageContext);
140
141 if (classExpr != null)
142 {
143 super.setClass(eval.evalString("class", classExpr)); //$NON-NLS-1$
144 }
145 if (dirExpr != null)
146 {
147 super.setDir(eval.evalString("dir", dirExpr)); //$NON-NLS-1$
148 }
149 if (idExpr != null)
150 {
151 super.setId(eval.evalString("id", idExpr)); //$NON-NLS-1$
152 }
153 if (langExpr != null)
154 {
155 super.setLang(eval.evalString("lang", langExpr)); //$NON-NLS-1$
156 }
157 if (mediaExpr != null)
158 {
159 super.setMedia(eval.evalString("media", mediaExpr)); //$NON-NLS-1$
160 }
161 if (styleExpr != null)
162 {
163 super.setStyle(eval.evalString("style", styleExpr)); //$NON-NLS-1$
164 }
165 if (titleExpr != null)
166 {
167 super.setTitle(eval.evalString("title", titleExpr)); //$NON-NLS-1$
168 }
169 }
170
171 /**
172 * @see javax.servlet.jsp.tagext.Tag#release()
173 */
174 public void release()
175 {
176 super.release();
177 this.classExpr = null;
178 this.dirExpr = null;
179 this.idExpr = null;
180 this.langExpr = null;
181 this.mediaExpr = null;
182 this.styleExpr = null;
183 this.titleExpr = null;
184 }
185
186 }