KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.displaytag.tags.SetPropertyTag;
17
18
19 /**
20  * Adds EL support to SetPropertyTag.
21  * @author Fabrizio Giustina
22  * @version $Revision: 720 $ ($Author: fgiust $)
23  */

24 public class ELSetPropertyTag extends SetPropertyTag
25 {
26
27     /**
28      * D1597A17A6.
29      */

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

35     private String JavaDoc nameExpr;
36
37     /**
38      * Expression for the "value" tag attribute.
39      */

40     private String JavaDoc valueExpr;
41
42     /**
43      * @see org.displaytag.tags.SetPropertyTag#setName(java.lang.String)
44      */

45     public void setName(String JavaDoc value)
46     {
47         nameExpr = value;
48     }
49
50     /**
51      * @see org.displaytag.tags.SetPropertyTag#setValue(java.lang.String)
52      */

53     public void setValue(String JavaDoc value)
54     {
55         valueExpr = value;
56     }
57
58     /**
59      * @see javax.servlet.jsp.tagext.Tag#doStartTag()
60      */

61     public int doStartTag() throws JspException JavaDoc
62     {
63         evaluateExpressions();
64         return super.doStartTag();
65     }
66
67     /**
68      * Evaluates the expressions for all the given attributes and pass results up to the parent tag.
69      * @throws JspException for exceptions occurred during evaluation.
70      */

71     private void evaluateExpressions() throws JspException JavaDoc
72     {
73         ExpressionEvaluator eval = new ExpressionEvaluator(this, pageContext);
74
75         super.setName(eval.evalString("name", nameExpr)); //$NON-NLS-1$
76

77         if (valueExpr != null)
78         {
79             super.setValue(eval.evalString("value", valueExpr)); //$NON-NLS-1$
80
}
81     }
82
83     /**
84      * @see javax.servlet.jsp.tagext.Tag#release()
85      */

86     public void release()
87     {
88         super.release();
89         this.nameExpr = null;
90         this.valueExpr = null;
91     }
92
93 }
Popular Tags