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.GetAttributeTag;
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.GetAttributeTag</code> which provides
35 * most of the described functionality. This subclass allows all attribute
36 * values to be specified as expressions utilizing the JavaServer Pages
37 * Standard Library expression language.
38 *
39 * @version $Rev: 376781 $
40 */
41 public class ELGetAttributeTag extends GetAttributeTag {
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 "role" tag attribute. (Mapping set in
56 * associated BeanInfo class.)
57 */
58 private String roleExpr;
59
60 /***
61 * Getter method for "name" tag attribute. (Mapping set in associated
62 * BeanInfo class.)
63 */
64 public String getNameExpr() {
65 return (nameExpr);
66 }
67
68 /***
69 * Getter method for "ignore" tag attribute. (Mapping set in associated
70 * BeanInfo class.)
71 */
72 public String getIgnoreExpr() {
73 return (ignoreExpr);
74 }
75
76 /***
77 * Getter method for "role" tag attribute. (Mapping set in associated
78 * BeanInfo class.)
79 */
80 public String getRoleExpr() {
81 return (roleExpr);
82 }
83
84 /***
85 * Setter method for "name" tag attribute. (Mapping set in associated
86 * BeanInfo class.)
87 */
88 public void setNameExpr(String nameExpr) {
89 this.nameExpr = nameExpr;
90 }
91
92 /***
93 * Setter method for "ignore" tag attribute. (Mapping set in associated
94 * BeanInfo class.)
95 */
96 public void setIgnoreExpr(String ignoreExpr) {
97 this.ignoreExpr = ignoreExpr;
98 }
99
100 /***
101 * Setter method for "role" tag attribute. (Mapping set in associated
102 * BeanInfo class.)
103 */
104 public void setRoleExpr(String roleExpr) {
105 this.roleExpr = roleExpr;
106 }
107
108 /***
109 * Resets attribute values for tag reuse.
110 */
111 public void release() {
112 super.release();
113 setNameExpr(null);
114 setIgnoreExpr(null);
115 setRoleExpr(null);
116 }
117
118 /***
119 * Process the start tag.
120 *
121 * @throws JspException if a JSP exception has occurred
122 */
123 public int doStartTag() throws JspException {
124 evaluateExpressions();
125
126 return (super.doStartTag());
127 }
128
129 /***
130 * Processes all attribute values which use the JSTL expression evaluation
131 * engine to determine their values.
132 *
133 * @throws JspException if a JSP exception has occurred
134 */
135 private void evaluateExpressions()
136 throws JspException {
137 String string = null;
138 Boolean bool = null;
139
140 if ((string =
141 EvalHelper.evalString("name", getNameExpr(), this, pageContext)) != null) {
142 setName(string);
143 }
144
145 if ((bool =
146 EvalHelper.evalBoolean("ignore", getIgnoreExpr(), this,
147 pageContext)) != null) {
148 setIgnore(bool.booleanValue());
149 }
150
151 if ((string =
152 EvalHelper.evalString("role", getRoleExpr(), this, pageContext)) != null) {
153 setRole(string);
154 }
155 }
156 }