001: /*
002: * $Id: ELNotPresentTag.java 471754 2006-11-06 14:55:09Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.strutsel.taglib.logic;
022:
023: import org.apache.struts.taglib.logic.NotPresentTag;
024: import org.apache.strutsel.taglib.utils.EvalHelper;
025:
026: import javax.servlet.jsp.JspException;
027:
028: /**
029: * Evaluates the nested body content of this tag if the specified value is not
030: * present for this request. <p> This class is a subclass of the class
031: * <code>org.apache.struts.taglib.logic.NotPresentTag</code> which provides
032: * most of the described functionality. This subclass allows all attribute
033: * values to be specified as expressions utilizing the JavaServer Pages
034: * Standard Library expression language.
035: *
036: * @version $Rev: 471754 $
037: */
038: public class ELNotPresentTag extends NotPresentTag {
039: /**
040: * Instance variable mapped to "cookie" tag attribute. (Mapping set in
041: * associated BeanInfo class.)
042: */
043: private String cookieExpr;
044:
045: /**
046: * Instance variable mapped to "header" tag attribute. (Mapping set in
047: * associated BeanInfo class.)
048: */
049: private String headerExpr;
050:
051: /**
052: * Instance variable mapped to "name" tag attribute. (Mapping set in
053: * associated BeanInfo class.)
054: */
055: private String nameExpr;
056:
057: /**
058: * Instance variable mapped to "parameter" tag attribute. (Mapping set in
059: * associated BeanInfo class.)
060: */
061: private String parameterExpr;
062:
063: /**
064: * Instance variable mapped to "property" tag attribute. (Mapping set in
065: * associated BeanInfo class.)
066: */
067: private String propertyExpr;
068:
069: /**
070: * Instance variable mapped to "role" tag attribute. (Mapping set in
071: * associated BeanInfo class.)
072: */
073: private String roleExpr;
074:
075: /**
076: * Instance variable mapped to "scope" tag attribute. (Mapping set in
077: * associated BeanInfo class.)
078: */
079: private String scopeExpr;
080:
081: /**
082: * Instance variable mapped to "user" tag attribute. (Mapping set in
083: * associated BeanInfo class.)
084: */
085: private String userExpr;
086:
087: /**
088: * Getter method for "cookie" tag attribute. (Mapping set in associated
089: * BeanInfo class.)
090: */
091: public String getCookieExpr() {
092: return (cookieExpr);
093: }
094:
095: /**
096: * Getter method for "header" tag attribute. (Mapping set in associated
097: * BeanInfo class.)
098: */
099: public String getHeaderExpr() {
100: return (headerExpr);
101: }
102:
103: /**
104: * Getter method for "name" tag attribute. (Mapping set in associated
105: * BeanInfo class.)
106: */
107: public String getNameExpr() {
108: return (nameExpr);
109: }
110:
111: /**
112: * Getter method for "parameter" tag attribute. (Mapping set in associated
113: * BeanInfo class.)
114: */
115: public String getParameterExpr() {
116: return (parameterExpr);
117: }
118:
119: /**
120: * Getter method for "property" tag attribute. (Mapping set in associated
121: * BeanInfo class.)
122: */
123: public String getPropertyExpr() {
124: return (propertyExpr);
125: }
126:
127: /**
128: * Getter method for "role" tag attribute. (Mapping set in associated
129: * BeanInfo class.)
130: */
131: public String getRoleExpr() {
132: return (roleExpr);
133: }
134:
135: /**
136: * Getter method for "scope" tag attribute. (Mapping set in associated
137: * BeanInfo class.)
138: */
139: public String getScopeExpr() {
140: return (scopeExpr);
141: }
142:
143: /**
144: * Getter method for "user" tag attribute. (Mapping set in associated
145: * BeanInfo class.)
146: */
147: public String getUserExpr() {
148: return (userExpr);
149: }
150:
151: /**
152: * Setter method for "cookie" tag attribute. (Mapping set in associated
153: * BeanInfo class.)
154: */
155: public void setCookieExpr(String cookieExpr) {
156: this .cookieExpr = cookieExpr;
157: }
158:
159: /**
160: * Setter method for "header" tag attribute. (Mapping set in associated
161: * BeanInfo class.)
162: */
163: public void setHeaderExpr(String headerExpr) {
164: this .headerExpr = headerExpr;
165: }
166:
167: /**
168: * Setter method for "name" tag attribute. (Mapping set in associated
169: * BeanInfo class.)
170: */
171: public void setNameExpr(String nameExpr) {
172: this .nameExpr = nameExpr;
173: }
174:
175: /**
176: * Setter method for "parameter" tag attribute. (Mapping set in associated
177: * BeanInfo class.)
178: */
179: public void setParameterExpr(String parameterExpr) {
180: this .parameterExpr = parameterExpr;
181: }
182:
183: /**
184: * Setter method for "property" tag attribute. (Mapping set in associated
185: * BeanInfo class.)
186: */
187: public void setPropertyExpr(String propertyExpr) {
188: this .propertyExpr = propertyExpr;
189: }
190:
191: /**
192: * Setter method for "role" tag attribute. (Mapping set in associated
193: * BeanInfo class.)
194: */
195: public void setRoleExpr(String roleExpr) {
196: this .roleExpr = roleExpr;
197: }
198:
199: /**
200: * Setter method for "scope" tag attribute. (Mapping set in associated
201: * BeanInfo class.)
202: */
203: public void setScopeExpr(String scopeExpr) {
204: this .scopeExpr = scopeExpr;
205: }
206:
207: /**
208: * Setter method for "user" tag attribute. (Mapping set in associated
209: * BeanInfo class.)
210: */
211: public void setUserExpr(String userExpr) {
212: this .userExpr = userExpr;
213: }
214:
215: /**
216: * Resets attribute values for tag reuse.
217: */
218: public void release() {
219: super .release();
220: setCookieExpr(null);
221: setHeaderExpr(null);
222: setNameExpr(null);
223: setParameterExpr(null);
224: setPropertyExpr(null);
225: setRoleExpr(null);
226: setScopeExpr(null);
227: setUserExpr(null);
228: }
229:
230: /**
231: * Process the start tag.
232: *
233: * @throws JspException if a JSP exception has occurred
234: */
235: public int doStartTag() throws JspException {
236: evaluateExpressions();
237:
238: return (super .doStartTag());
239: }
240:
241: /**
242: * Processes all attribute values which use the JSTL expression evaluation
243: * engine to determine their values.
244: *
245: * @throws JspException if a JSP exception has occurred
246: */
247: private void evaluateExpressions() throws JspException {
248: String string = null;
249:
250: if ((string = EvalHelper.evalString("cookie", getCookieExpr(),
251: this , pageContext)) != null) {
252: setCookie(string);
253: }
254:
255: if ((string = EvalHelper.evalString("header", getHeaderExpr(),
256: this , pageContext)) != null) {
257: setHeader(string);
258: }
259:
260: if ((string = EvalHelper.evalString("name", getNameExpr(),
261: this , pageContext)) != null) {
262: setName(string);
263: }
264:
265: if ((string = EvalHelper.evalString("parameter",
266: getParameterExpr(), this , pageContext)) != null) {
267: setParameter(string);
268: }
269:
270: if ((string = EvalHelper.evalString("property",
271: getPropertyExpr(), this , pageContext)) != null) {
272: setProperty(string);
273: }
274:
275: if ((string = EvalHelper.evalString("role", getRoleExpr(),
276: this , pageContext)) != null) {
277: setRole(string);
278: }
279:
280: if ((string = EvalHelper.evalString("scope", getScopeExpr(),
281: this , pageContext)) != null) {
282: setScope(string);
283: }
284:
285: if ((string = EvalHelper.evalString("user", getUserExpr(),
286: this, pageContext)) != null) {
287: setUser(string);
288: }
289: }
290: }
|