View Javadoc

1   /*
2    * $Id: ELAddTag.java 376781 2006-02-10 18:09:48Z husted $
3    *
4    * Copyright 1999-2004 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.strutsel.taglib.tiles;
19  
20  import org.apache.struts.tiles.taglib.AddTag;
21  import org.apache.strutsel.taglib.utils.EvalHelper;
22  
23  import javax.servlet.jsp.JspException;
24  
25  /***
26   * Adds an element to the surrounding list tag.  Same syntax as
27   * <code>&lt;put&gt;</code>. <p> This class is a subclass of the class
28   * <code>org.apache.struts.taglib.tiles.AddTag</code> which provides most of
29   * the described functionality.  This subclass allows all attribute values to
30   * be specified as expressions utilizing the JavaServer Pages Standard Library
31   * expression language.
32   *
33   * @version $Rev: 376781 $
34   */
35  public class ELAddTag extends AddTag {
36      /***
37       * Instance variable mapped to "value" tag attribute. (Mapping set in
38       * associated BeanInfo class.)
39       */
40      private String valueExpr;
41  
42      /***
43       * Instance variable mapped to "content" tag attribute. (Mapping set in
44       * associated BeanInfo class.)
45       */
46      private String contentExpr;
47  
48      /***
49       * Instance variable mapped to "direct" tag attribute. (Mapping set in
50       * associated BeanInfo class.)
51       */
52      private String directExpr;
53  
54      /***
55       * Instance variable mapped to "type" tag attribute. (Mapping set in
56       * associated BeanInfo class.)
57       */
58      private String typeExpr;
59  
60      /***
61       * Instance variable mapped to "beanName" tag attribute. (Mapping set in
62       * associated BeanInfo class.)
63       */
64      private String beanNameExpr;
65  
66      /***
67       * Instance variable mapped to "beanProperty" tag attribute. (Mapping set
68       * in associated BeanInfo class.)
69       */
70      private String beanPropertyExpr;
71  
72      /***
73       * Instance variable mapped to "beanScope" tag attribute. (Mapping set in
74       * associated BeanInfo class.)
75       */
76      private String beanScopeExpr;
77  
78      /***
79       * Instance variable mapped to "role" tag attribute. (Mapping set in
80       * associated BeanInfo class.)
81       */
82      private String roleExpr;
83  
84      /***
85       * Getter method for "value" tag attribute. (Mapping set in associated
86       * BeanInfo class.)
87       */
88      public String getValueExpr() {
89          return (valueExpr);
90      }
91  
92      /***
93       * Getter method for "content" tag attribute. (Mapping set in associated
94       * BeanInfo class.)
95       */
96      public String getContentExpr() {
97          return (contentExpr);
98      }
99  
100     /***
101      * Getter method for "direct" tag attribute. (Mapping set in associated
102      * BeanInfo class.)
103      */
104     public String getDirectExpr() {
105         return (directExpr);
106     }
107 
108     /***
109      * Getter method for "type" tag attribute. (Mapping set in associated
110      * BeanInfo class.)
111      */
112     public String getTypeExpr() {
113         return (typeExpr);
114     }
115 
116     /***
117      * Getter method for "beanName" tag attribute. (Mapping set in associated
118      * BeanInfo class.)
119      */
120     public String getBeanNameExpr() {
121         return (beanNameExpr);
122     }
123 
124     /***
125      * Getter method for "beanProperty" tag attribute. (Mapping set in
126      * associated BeanInfo class.)
127      */
128     public String getBeanPropertyExpr() {
129         return (beanPropertyExpr);
130     }
131 
132     /***
133      * Getter method for "beanScope" tag attribute. (Mapping set in associated
134      * BeanInfo class.)
135      */
136     public String getBeanScopeExpr() {
137         return (beanScopeExpr);
138     }
139 
140     /***
141      * Getter method for "role" tag attribute. (Mapping set in associated
142      * BeanInfo class.)
143      */
144     public String getRoleExpr() {
145         return (roleExpr);
146     }
147 
148     /***
149      * Setter method for "value" tag attribute. (Mapping set in associated
150      * BeanInfo class.)
151      */
152     public void setValueExpr(String valueExpr) {
153         this.valueExpr = valueExpr;
154     }
155 
156     /***
157      * Setter method for "content" tag attribute. (Mapping set in associated
158      * BeanInfo class.)
159      */
160     public void setContentExpr(String contentExpr) {
161         this.contentExpr = contentExpr;
162     }
163 
164     /***
165      * Setter method for "direct" tag attribute. (Mapping set in associated
166      * BeanInfo class.)
167      */
168     public void setDirectExpr(String directExpr) {
169         this.directExpr = directExpr;
170     }
171 
172     /***
173      * Setter method for "type" tag attribute. (Mapping set in associated
174      * BeanInfo class.)
175      */
176     public void setTypeExpr(String typeExpr) {
177         this.typeExpr = typeExpr;
178     }
179 
180     /***
181      * Setter method for "beanName" tag attribute. (Mapping set in associated
182      * BeanInfo class.)
183      */
184     public void setBeanNameExpr(String beanNameExpr) {
185         this.beanNameExpr = beanNameExpr;
186     }
187 
188     /***
189      * Setter method for "beanProperty" tag attribute. (Mapping set in
190      * associated BeanInfo class.)
191      */
192     public void setBeanPropertyExpr(String beanPropertyExpr) {
193         this.beanPropertyExpr = beanPropertyExpr;
194     }
195 
196     /***
197      * Setter method for "beanScope" tag attribute. (Mapping set in associated
198      * BeanInfo class.)
199      */
200     public void setBeanScopeExpr(String beanScopeExpr) {
201         this.beanScopeExpr = beanScopeExpr;
202     }
203 
204     /***
205      * Setter method for "role" tag attribute. (Mapping set in associated
206      * BeanInfo class.)
207      */
208     public void setRoleExpr(String roleExpr) {
209         this.roleExpr = roleExpr;
210     }
211 
212     /***
213      * Resets attribute values for tag reuse.
214      */
215     public void release() {
216         super.release();
217         setValueExpr(null);
218         setContentExpr(null);
219         setDirectExpr(null);
220         setTypeExpr(null);
221         setBeanNameExpr(null);
222         setBeanPropertyExpr(null);
223         setBeanScopeExpr(null);
224         setRoleExpr(null);
225     }
226 
227     /***
228      * Process the start tag.
229      *
230      * @throws JspException if a JSP exception has occurred
231      */
232     public int doStartTag() throws JspException {
233         evaluateExpressions();
234 
235         return (super.doStartTag());
236     }
237 
238     /***
239      * Processes all attribute values which use the JSTL expression evaluation
240      * engine to determine their values.
241      *
242      * @throws JspException if a JSP exception has occurred
243      */
244     private void evaluateExpressions()
245         throws JspException {
246         String string = null;
247 
248         if ((string =
249                 EvalHelper.evalString("value", getValueExpr(), this, pageContext)) != null) {
250             setValue(string);
251         }
252 
253         if ((string =
254                 EvalHelper.evalString("content", getContentExpr(), this,
255                     pageContext)) != null) {
256             setContent(string);
257         }
258 
259         if ((string =
260                 EvalHelper.evalString("direct", getDirectExpr(), this,
261                     pageContext)) != null) {
262             setDirect(string);
263         }
264 
265         if ((string =
266                 EvalHelper.evalString("type", getTypeExpr(), this, pageContext)) != null) {
267             setType(string);
268         }
269 
270         if ((string =
271                 EvalHelper.evalString("beanName", getBeanNameExpr(), this,
272                     pageContext)) != null) {
273             setBeanName(string);
274         }
275 
276         if ((string =
277                 EvalHelper.evalString("beanProperty", getBeanPropertyExpr(),
278                     this, pageContext)) != null) {
279             setBeanProperty(string);
280         }
281 
282         if ((string =
283                 EvalHelper.evalString("beanScope", getBeanScopeExpr(), this,
284                     pageContext)) != null) {
285             setBeanScope(string);
286         }
287 
288         if ((string =
289                 EvalHelper.evalString("role", getRoleExpr(), this, pageContext)) != null) {
290             setRole(string);
291         }
292     }
293 }