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