KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > strutsel > taglib > logic > ELNotPresentTag


1 /*
2  * $Id: ELNotPresentTag.java 54933 2004-10-16 17:04:52Z germuska $
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
19 package org.apache.strutsel.taglib.logic;
20
21 import org.apache.struts.taglib.logic.NotPresentTag;
22 import javax.servlet.jsp.JspException JavaDoc;
23 import org.apache.strutsel.taglib.utils.EvalHelper;
24
25 /**
26  * Evaluates the nested body content of this tag if the specified value is
27  * not present for this request.
28  *<p>
29  * This class is a subclass of the class
30  * <code>org.apache.struts.taglib.logic.NotPresentTag</code> which
31  * provides most of the described functionality. This subclass allows all
32  * attribute values to be specified as expressions utilizing the JavaServer
33  * Pages Standard Library expression language.
34  *
35  * @version $Rev: 54933 $
36  */

37 public class ELNotPresentTag extends NotPresentTag {
38
39     /**
40      * Instance variable mapped to "cookie" tag attribute.
41      * (Mapping set in associated BeanInfo class.)
42      */

43     private String JavaDoc cookieExpr;
44     /**
45      * Instance variable mapped to "header" tag attribute.
46      * (Mapping set in associated BeanInfo class.)
47      */

48     private String JavaDoc headerExpr;
49     /**
50      * Instance variable mapped to "name" tag attribute.
51      * (Mapping set in associated BeanInfo class.)
52      */

53     private String JavaDoc nameExpr;
54     /**
55      * Instance variable mapped to "parameter" tag attribute.
56      * (Mapping set in associated BeanInfo class.)
57      */

58     private String JavaDoc parameterExpr;
59     /**
60      * Instance variable mapped to "property" tag attribute.
61      * (Mapping set in associated BeanInfo class.)
62      */

63     private String JavaDoc propertyExpr;
64     /**
65      * Instance variable mapped to "role" tag attribute.
66      * (Mapping set in associated BeanInfo class.)
67      */

68     private String JavaDoc roleExpr;
69     /**
70      * Instance variable mapped to "scope" tag attribute.
71      * (Mapping set in associated BeanInfo class.)
72      */

73     private String JavaDoc scopeExpr;
74     /**
75      * Instance variable mapped to "user" tag attribute.
76      * (Mapping set in associated BeanInfo class.)
77      */

78     private String JavaDoc userExpr;
79
80     /**
81      * Getter method for "cookie" tag attribute.
82      * (Mapping set in associated BeanInfo class.)
83      */

84     public String JavaDoc getCookieExpr() { return (cookieExpr); }
85     /**
86      * Getter method for "header" tag attribute.
87      * (Mapping set in associated BeanInfo class.)
88      */

89     public String JavaDoc getHeaderExpr() { return (headerExpr); }
90     /**
91      * Getter method for "name" tag attribute.
92      * (Mapping set in associated BeanInfo class.)
93      */

94     public String JavaDoc getNameExpr() { return (nameExpr); }
95     /**
96      * Getter method for "parameter" tag attribute.
97      * (Mapping set in associated BeanInfo class.)
98      */

99     public String JavaDoc getParameterExpr() { return (parameterExpr); }
100     /**
101      * Getter method for "property" tag attribute.
102      * (Mapping set in associated BeanInfo class.)
103      */

104     public String JavaDoc getPropertyExpr() { return (propertyExpr); }
105     /**
106      * Getter method for "role" tag attribute.
107      * (Mapping set in associated BeanInfo class.)
108      */

109     public String JavaDoc getRoleExpr() { return (roleExpr); }
110     /**
111      * Getter method for "scope" tag attribute.
112      * (Mapping set in associated BeanInfo class.)
113      */

114     public String JavaDoc getScopeExpr() { return (scopeExpr); }
115     /**
116      * Getter method for "user" tag attribute.
117      * (Mapping set in associated BeanInfo class.)
118      */

119     public String JavaDoc getUserExpr() { return (userExpr); }
120
121     /**
122      * Setter method for "cookie" tag attribute.
123      * (Mapping set in associated BeanInfo class.)
124      */

125     public void setCookieExpr(String JavaDoc cookieExpr) { this.cookieExpr = cookieExpr; }
126     /**
127      * Setter method for "header" tag attribute.
128      * (Mapping set in associated BeanInfo class.)
129      */

130     public void setHeaderExpr(String JavaDoc headerExpr) { this.headerExpr = headerExpr; }
131     /**
132      * Setter method for "name" tag attribute.
133      * (Mapping set in associated BeanInfo class.)
134      */

135     public void setNameExpr(String JavaDoc nameExpr) { this.nameExpr = nameExpr; }
136     /**
137      * Setter method for "parameter" tag attribute.
138      * (Mapping set in associated BeanInfo class.)
139      */

140     public void setParameterExpr(String JavaDoc parameterExpr) { this.parameterExpr = parameterExpr; }
141     /**
142      * Setter method for "property" tag attribute.
143      * (Mapping set in associated BeanInfo class.)
144      */

145     public void setPropertyExpr(String JavaDoc propertyExpr) { this.propertyExpr = propertyExpr; }
146     /**
147      * Setter method for "role" tag attribute.
148      * (Mapping set in associated BeanInfo class.)
149      */

150     public void setRoleExpr(String JavaDoc roleExpr) { this.roleExpr = roleExpr; }
151     /**
152      * Setter method for "scope" tag attribute.
153      * (Mapping set in associated BeanInfo class.)
154      */

155     public void setScopeExpr(String JavaDoc scopeExpr) { this.scopeExpr = scopeExpr; }
156     /**
157      * Setter method for "user" tag attribute.
158      * (Mapping set in associated BeanInfo class.)
159      */

160     public void setUserExpr(String JavaDoc userExpr) { this.userExpr = userExpr; }
161
162     /**
163      * Resets attribute values for tag reuse.
164      */

165     public void release()
166     {
167         super.release();
168         setCookieExpr(null);
169         setHeaderExpr(null);
170         setNameExpr(null);
171         setParameterExpr(null);
172         setPropertyExpr(null);
173         setRoleExpr(null);
174         setScopeExpr(null);
175         setUserExpr(null);
176     }
177     
178     /**
179      * Process the start tag.
180      *
181      * @exception JspException if a JSP exception has occurred
182      */

183     public int doStartTag() throws JspException JavaDoc {
184         evaluateExpressions();
185         return (super.doStartTag());
186     }
187
188     /**
189      * Processes all attribute values which use the JSTL expression evaluation
190      * engine to determine their values.
191      *
192      * @exception JspException if a JSP exception has occurred
193      */

194     private void evaluateExpressions() throws JspException JavaDoc {
195         String JavaDoc string = null;
196
197         if ((string = EvalHelper.evalString("cookie", getCookieExpr(),
198                                             this, pageContext)) != null)
199             setCookie(string);
200
201         if ((string = EvalHelper.evalString("header", getHeaderExpr(),
202                                             this, pageContext)) != null)
203             setHeader(string);
204
205         if ((string = EvalHelper.evalString("name", getNameExpr(),
206                                             this, pageContext)) != null)
207             setName(string);
208
209         if ((string = EvalHelper.evalString("parameter", getParameterExpr(),
210                                             this, pageContext)) != null)
211             setParameter(string);
212
213         if ((string = EvalHelper.evalString("property", getPropertyExpr(),
214                                             this, pageContext)) != null)
215             setProperty(string);
216
217         if ((string = EvalHelper.evalString("role", getRoleExpr(),
218                                             this, pageContext)) != null)
219             setRole(string);
220
221         if ((string = EvalHelper.evalString("scope", getScopeExpr(),
222                                             this, pageContext)) != null)
223             setScope(string);
224
225         if ((string = EvalHelper.evalString("user", getUserExpr(),
226                                             this, pageContext)) != null)
227             setUser(string);
228     }
229 }
230
Popular Tags