1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.strutsel.taglib.html;
22
23 import org.apache.struts.taglib.html.ParamTag;
24 import org.apache.strutsel.taglib.utils.EvalHelper;
25
26 import javax.servlet.jsp.JspException;
27
28 /**
29 * Adds a new request parameter to its parent {@link ELLinkTag}. This subclass
30 * allows all attribute values to be specified as expressions utilizing the
31 * JavaServer Pages Standard Library expression language.
32 *
33 * @version $Rev: 482911 $ $Date: 2006-12-05 23:44:33 -0600 (Tue, 05 Dec 2006) $
34 * @since Struts 1.3.6
35 */
36 public class ELParamTag extends ParamTag {
37
38 /**
39 * Instance variable mapped to "name" tag attribute. (Mapping set in
40 * associated BeanInfo class.)
41 */
42 private String nameExpr;
43
44 /**
45 * Instance variable mapped to "value" tag attribute. (Mapping set in
46 * associated BeanInfo class.)
47 */
48 private String valueExpr;
49
50 /**
51 * Getter method for "name" tag attribute. (Mapping set in associated
52 * BeanInfo class.)
53 */
54 public String getNameExpr() {
55 return (nameExpr);
56 }
57
58 /**
59 * Getter method for "value" tag attribute. (Mapping set in associated
60 * BeanInfo class.)
61 */
62 public String getValueExpr() {
63 return (valueExpr);
64 }
65
66 /**
67 * Setter method for "name" tag attribute. (Mapping set in associated
68 * BeanInfo class.)
69 */
70 public void setNameExpr(String nameExpr) {
71 this.nameExpr = nameExpr;
72 }
73
74 /**
75 * Setter method for "value" tag attribute. (Mapping set in associated
76 * BeanInfo class.)
77 */
78 public void setValueExpr(String valueExpr) {
79 this.valueExpr = valueExpr;
80 }
81
82 /**
83 * Resets attribute values for tag reuse.
84 */
85 public void release() {
86 super.release();
87 setNameExpr(null);
88 setValueExpr(null);
89 }
90
91 /**
92 * Process the start tag.
93 *
94 * @throws JspException if a JSP exception has occurred
95 */
96 public int doStartTag() throws JspException {
97 evaluateExpressions();
98
99 return (super.doStartTag());
100 }
101
102 /**
103 * Processes all attribute values which use the JSTL expression evaluation
104 * engine to determine their values.
105 *
106 * @throws JspException if a JSP exception has occurred
107 */
108 private void evaluateExpressions() throws JspException {
109 String string = null;
110
111 if ((string = EvalHelper.evalString("name", getNameExpr(), this,
112 pageContext)) != null) {
113 setName(string);
114 }
115
116 if ((string = EvalHelper.evalString("value", getValueExpr(), this,
117 pageContext)) != null) {
118 setValue(string);
119 }
120 }
121 }