1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.strutsel.taglib.bean;
19
20 import org.apache.struts.taglib.bean.PageTag;
21 import org.apache.strutsel.taglib.utils.EvalHelper;
22
23 import javax.servlet.jsp.JspException;
24
25 /***
26 * Define a scripting variable that exposes the requested page context item as
27 * a scripting variable and a page scope bean. <p> This class is a subclass of
28 * the class <code>org.apache.struts.taglib.bean.PageTag</code> which provides
29 * most of the described functionality. This subclass allows all attribute
30 * values to be specified as expressions utilizing the JavaServer Pages
31 * Standard Library expression language.
32 *
33 * @version $Rev: 376778 $
34 */
35 public class ELPageTag extends PageTag {
36 /***
37 * Instance variable mapped to "id" tag attribute. (Mapping set in
38 * associated BeanInfo class.)
39 */
40 private String idExpr;
41
42 /***
43 * Instance variable mapped to "property" tag attribute. (Mapping set in
44 * associated BeanInfo class.)
45 */
46 private String propertyExpr;
47
48 /***
49 * Getter method for "id" tag attribute. (Mapping set in associated
50 * BeanInfo class.)
51 */
52 public String getIdExpr() {
53 return (idExpr);
54 }
55
56 /***
57 * Getter method for "property" tag attribute. (Mapping set in associated
58 * BeanInfo class.)
59 */
60 public String getPropertyExpr() {
61 return (propertyExpr);
62 }
63
64 /***
65 * Setter method for "id" tag attribute. (Mapping set in associated
66 * BeanInfo class.)
67 */
68 public void setIdExpr(String idExpr) {
69 this.idExpr = idExpr;
70 }
71
72 /***
73 * Setter method for "property" tag attribute. (Mapping set in associated
74 * BeanInfo class.)
75 */
76 public void setPropertyExpr(String propertyExpr) {
77 this.propertyExpr = propertyExpr;
78 }
79
80 /***
81 * Resets attribute values for tag reuse.
82 */
83 public void release() {
84 super.release();
85 setIdExpr(null);
86 setPropertyExpr(null);
87 }
88
89 /***
90 * Process the start tag.
91 *
92 * @throws JspException if a JSP exception has occurred
93 */
94 public int doStartTag() throws JspException {
95 evaluateExpressions();
96
97 return (super.doStartTag());
98 }
99
100 /***
101 * Processes all attribute values which use the JSTL expression evaluation
102 * engine to determine their values.
103 *
104 * @throws JspException if a JSP exception has occurred
105 */
106 private void evaluateExpressions()
107 throws JspException {
108 String string = null;
109
110 if ((string =
111 EvalHelper.evalString("id", getIdExpr(), this, pageContext)) != null) {
112 setId(string);
113 }
114
115 if ((string =
116 EvalHelper.evalString("property", getPropertyExpr(), this,
117 pageContext)) != null) {
118 setProperty(string);
119 }
120 }
121 }