View Javadoc

1   /*
2    * $Id: ELNotPresentTag.java 376780 2006-02-10 18:09:22Z 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.logic;
19  
20  import org.apache.struts.taglib.logic.NotPresentTag;
21  import org.apache.strutsel.taglib.utils.EvalHelper;
22  
23  import javax.servlet.jsp.JspException;
24  
25  /***
26   * Evaluates the nested body content of this tag if the specified value is not
27   * present for this request. <p> This class is a subclass of the class
28   * <code>org.apache.struts.taglib.logic.NotPresentTag</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: 376780 $
34   */
35  public class ELNotPresentTag extends NotPresentTag {
36      /***
37       * Instance variable mapped to "cookie" tag attribute. (Mapping set in
38       * associated BeanInfo class.)
39       */
40      private String cookieExpr;
41  
42      /***
43       * Instance variable mapped to "header" tag attribute. (Mapping set in
44       * associated BeanInfo class.)
45       */
46      private String headerExpr;
47  
48      /***
49       * Instance variable mapped to "name" tag attribute. (Mapping set in
50       * associated BeanInfo class.)
51       */
52      private String nameExpr;
53  
54      /***
55       * Instance variable mapped to "parameter" tag attribute. (Mapping set in
56       * associated BeanInfo class.)
57       */
58      private String parameterExpr;
59  
60      /***
61       * Instance variable mapped to "property" tag attribute. (Mapping set in
62       * associated BeanInfo class.)
63       */
64      private String propertyExpr;
65  
66      /***
67       * Instance variable mapped to "role" tag attribute. (Mapping set in
68       * associated BeanInfo class.)
69       */
70      private String roleExpr;
71  
72      /***
73       * Instance variable mapped to "scope" tag attribute. (Mapping set in
74       * associated BeanInfo class.)
75       */
76      private String scopeExpr;
77  
78      /***
79       * Instance variable mapped to "user" tag attribute. (Mapping set in
80       * associated BeanInfo class.)
81       */
82      private String userExpr;
83  
84      /***
85       * Getter method for "cookie" tag attribute. (Mapping set in associated
86       * BeanInfo class.)
87       */
88      public String getCookieExpr() {
89          return (cookieExpr);
90      }
91  
92      /***
93       * Getter method for "header" tag attribute. (Mapping set in associated
94       * BeanInfo class.)
95       */
96      public String getHeaderExpr() {
97          return (headerExpr);
98      }
99  
100     /***
101      * Getter method for "name" tag attribute. (Mapping set in associated
102      * BeanInfo class.)
103      */
104     public String getNameExpr() {
105         return (nameExpr);
106     }
107 
108     /***
109      * Getter method for "parameter" tag attribute. (Mapping set in associated
110      * BeanInfo class.)
111      */
112     public String getParameterExpr() {
113         return (parameterExpr);
114     }
115 
116     /***
117      * Getter method for "property" tag attribute. (Mapping set in associated
118      * BeanInfo class.)
119      */
120     public String getPropertyExpr() {
121         return (propertyExpr);
122     }
123 
124     /***
125      * Getter method for "role" tag attribute. (Mapping set in associated
126      * BeanInfo class.)
127      */
128     public String getRoleExpr() {
129         return (roleExpr);
130     }
131 
132     /***
133      * Getter method for "scope" tag attribute. (Mapping set in associated
134      * BeanInfo class.)
135      */
136     public String getScopeExpr() {
137         return (scopeExpr);
138     }
139 
140     /***
141      * Getter method for "user" tag attribute. (Mapping set in associated
142      * BeanInfo class.)
143      */
144     public String getUserExpr() {
145         return (userExpr);
146     }
147 
148     /***
149      * Setter method for "cookie" tag attribute. (Mapping set in associated
150      * BeanInfo class.)
151      */
152     public void setCookieExpr(String cookieExpr) {
153         this.cookieExpr = cookieExpr;
154     }
155 
156     /***
157      * Setter method for "header" tag attribute. (Mapping set in associated
158      * BeanInfo class.)
159      */
160     public void setHeaderExpr(String headerExpr) {
161         this.headerExpr = headerExpr;
162     }
163 
164     /***
165      * Setter method for "name" tag attribute. (Mapping set in associated
166      * BeanInfo class.)
167      */
168     public void setNameExpr(String nameExpr) {
169         this.nameExpr = nameExpr;
170     }
171 
172     /***
173      * Setter method for "parameter" tag attribute. (Mapping set in associated
174      * BeanInfo class.)
175      */
176     public void setParameterExpr(String parameterExpr) {
177         this.parameterExpr = parameterExpr;
178     }
179 
180     /***
181      * Setter method for "property" tag attribute. (Mapping set in associated
182      * BeanInfo class.)
183      */
184     public void setPropertyExpr(String propertyExpr) {
185         this.propertyExpr = propertyExpr;
186     }
187 
188     /***
189      * Setter method for "role" tag attribute. (Mapping set in associated
190      * BeanInfo class.)
191      */
192     public void setRoleExpr(String roleExpr) {
193         this.roleExpr = roleExpr;
194     }
195 
196     /***
197      * Setter method for "scope" tag attribute. (Mapping set in associated
198      * BeanInfo class.)
199      */
200     public void setScopeExpr(String scopeExpr) {
201         this.scopeExpr = scopeExpr;
202     }
203 
204     /***
205      * Setter method for "user" tag attribute. (Mapping set in associated
206      * BeanInfo class.)
207      */
208     public void setUserExpr(String userExpr) {
209         this.userExpr = userExpr;
210     }
211 
212     /***
213      * Resets attribute values for tag reuse.
214      */
215     public void release() {
216         super.release();
217         setCookieExpr(null);
218         setHeaderExpr(null);
219         setNameExpr(null);
220         setParameterExpr(null);
221         setPropertyExpr(null);
222         setRoleExpr(null);
223         setScopeExpr(null);
224         setUserExpr(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("cookie", getCookieExpr(), this,
250                     pageContext)) != null) {
251             setCookie(string);
252         }
253 
254         if ((string =
255                 EvalHelper.evalString("header", getHeaderExpr(), this,
256                     pageContext)) != null) {
257             setHeader(string);
258         }
259 
260         if ((string =
261                 EvalHelper.evalString("name", getNameExpr(), this, pageContext)) != null) {
262             setName(string);
263         }
264 
265         if ((string =
266                 EvalHelper.evalString("parameter", getParameterExpr(), this,
267                     pageContext)) != null) {
268             setParameter(string);
269         }
270 
271         if ((string =
272                 EvalHelper.evalString("property", getPropertyExpr(), this,
273                     pageContext)) != null) {
274             setProperty(string);
275         }
276 
277         if ((string =
278                 EvalHelper.evalString("role", getRoleExpr(), this, pageContext)) != null) {
279             setRole(string);
280         }
281 
282         if ((string =
283                 EvalHelper.evalString("scope", getScopeExpr(), this, pageContext)) != null) {
284             setScope(string);
285         }
286 
287         if ((string =
288                 EvalHelper.evalString("user", getUserExpr(), this, pageContext)) != null) {
289             setUser(string);
290         }
291     }
292 }