1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.strutsel.taglib.tiles;
19
20 import org.apache.struts.tiles.taglib.GetTag;
21 import org.apache.strutsel.taglib.utils.EvalHelper;
22
23 import javax.servlet.jsp.JspException;
24
25 /***
26 * This is the tag handler for <tiles-el:get>, which gets content from
27 * the request scope and either includes the content or prints it, depending
28 * upon the value of the content's <code>direct</code> attribute. <p> This tag
29 * is intended to be compatible with the same tag from Templates (David
30 * Geary). Implementation extends InsertTag for facility (no so well). The
31 * only difference is the default value of attribute 'ignore', which is
32 * <code>true</code> for this tag (default behavior of David Geary's
33 * templates). <p> This class is a subclass of the class
34 * <code>org.apache.struts.taglib.tiles.GetTag</code> which provides most of
35 * the described functionality. This subclass allows all attribute values to
36 * be specified as expressions utilizing the JavaServer Pages Standard Library
37 * expression language.
38 *
39 * @version $Rev: 376781 $
40 */
41 public class ELGetTag extends GetTag {
42 /***
43 * Instance variable mapped to "name" tag attribute. (Mapping set in
44 * associated BeanInfo class.)
45 */
46 private String nameExpr;
47
48 /***
49 * Instance variable mapped to "ignore" tag attribute. (Mapping set in
50 * associated BeanInfo class.)
51 */
52 private String ignoreExpr;
53
54 /***
55 * Instance variable mapped to "flush" tag attribute. (Mapping set in
56 * associated BeanInfo class.)
57 */
58 private String flushExpr;
59
60 /***
61 * Instance variable mapped to "role" tag attribute. (Mapping set in
62 * associated BeanInfo class.)
63 */
64 private String roleExpr;
65
66 /***
67 * Getter method for "name" tag attribute. (Mapping set in associated
68 * BeanInfo class.)
69 */
70 public String getNameExpr() {
71 return (nameExpr);
72 }
73
74 /***
75 * Getter method for "ignore" tag attribute. (Mapping set in associated
76 * BeanInfo class.)
77 */
78 public String getIgnoreExpr() {
79 return (ignoreExpr);
80 }
81
82 /***
83 * Getter method for "flush" tag attribute. (Mapping set in associated
84 * BeanInfo class.)
85 */
86 public String getFlushExpr() {
87 return (flushExpr);
88 }
89
90 /***
91 * Getter method for "role" tag attribute. (Mapping set in associated
92 * BeanInfo class.)
93 */
94 public String getRoleExpr() {
95 return (roleExpr);
96 }
97
98 /***
99 * Setter method for "name" tag attribute. (Mapping set in associated
100 * BeanInfo class.)
101 */
102 public void setNameExpr(String nameExpr) {
103 this.nameExpr = nameExpr;
104 }
105
106 /***
107 * Setter method for "ignore" tag attribute. (Mapping set in associated
108 * BeanInfo class.)
109 */
110 public void setIgnoreExpr(String ignoreExpr) {
111 this.ignoreExpr = ignoreExpr;
112 }
113
114 /***
115 * Setter method for "flush" tag attribute. (Mapping set in associated
116 * BeanInfo class.)
117 */
118 public void setFlushExpr(String flushExpr) {
119 this.flushExpr = flushExpr;
120 }
121
122 /***
123 * Setter method for "role" tag attribute. (Mapping set in associated
124 * BeanInfo class.)
125 */
126 public void setRoleExpr(String roleExpr) {
127 this.roleExpr = roleExpr;
128 }
129
130 /***
131 * Resets attribute values for tag reuse.
132 */
133 public void release() {
134 super.release();
135 setNameExpr(null);
136 setIgnoreExpr(null);
137 setFlushExpr(null);
138 setRoleExpr(null);
139 }
140
141 /***
142 * Process the start tag.
143 *
144 * @throws JspException if a JSP exception has occurred
145 */
146 public int doStartTag() throws JspException {
147 evaluateExpressions();
148
149 return (super.doStartTag());
150 }
151
152 /***
153 * Processes all attribute values which use the JSTL expression evaluation
154 * engine to determine their values.
155 *
156 * @throws JspException if a JSP exception has occurred
157 */
158 private void evaluateExpressions()
159 throws JspException {
160 String string = null;
161 Boolean bool = null;
162
163 if ((string =
164 EvalHelper.evalString("name", getNameExpr(), this, pageContext)) != null) {
165 setName(string);
166 }
167
168 if ((bool =
169 EvalHelper.evalBoolean("ignore", getIgnoreExpr(), this,
170 pageContext)) != null) {
171 setIgnore(bool.booleanValue());
172 }
173
174 if ((string =
175 EvalHelper.evalString("flush", getFlushExpr(), this, pageContext)) != null) {
176 setFlush(string);
177 }
178
179 if ((string =
180 EvalHelper.evalString("role", getRoleExpr(), this, pageContext)) != null) {
181 setRole(string);
182 }
183 }
184 }