001: /*
002: * $Id: ELOptionTag.java 479635 2006-11-27 14:27:18Z pbenedict $
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.html;
022:
023: import org.apache.struts.taglib.html.OptionTag;
024: import org.apache.strutsel.taglib.utils.EvalHelper;
025:
026: import javax.servlet.jsp.JspException;
027:
028: /**
029: * Tag for select options. The body of this tag is presented to the user in
030: * the option list, while the value attribute is the value returned to the
031: * server if this option is selected. <p> This class is a subclass of the
032: * class <code>org.apache.struts.taglib.html.OptionTag</code> which provides
033: * most of the described functionality. This subclass allows all attribute
034: * values to be specified as expressions utilizing the JavaServer Pages
035: * Standard Library expression language.
036: *
037: * @version $Rev: 479635 $
038: */
039: public class ELOptionTag extends OptionTag {
040: /**
041: * Instance variable mapped to "bundle" tag attribute. (Mapping set in
042: * associated BeanInfo class.)
043: */
044: private String bundleExpr;
045:
046: /**
047: * Instance variable mapped to "dir" tag attribute. (Mapping set in
048: * associated BeanInfo class.)
049: */
050: private String dirExpr;
051:
052: /**
053: * Instance variable mapped to "disabled" tag attribute. (Mapping set in
054: * associated BeanInfo class.)
055: */
056: private String disabledExpr;
057:
058: /**
059: * Instance variable mapped to "filter" tag attribute. (Mapping set in
060: * associated BeanInfo class.)
061: */
062: private String filterExpr;
063:
064: /**
065: * Instance variable mapped to "lang" tag attribute. (Mapping set in
066: * associated BeanInfo class.)
067: */
068: private String langExpr;
069:
070: /**
071: * Instance variable mapped to "key" tag attribute. (Mapping set in
072: * associated BeanInfo class.)
073: */
074: private String keyExpr;
075:
076: /**
077: * Instance variable mapped to "locale" tag attribute. (Mapping set in
078: * associated BeanInfo class.)
079: */
080: private String localeExpr;
081:
082: /**
083: * Instance variable mapped to "style" tag attribute. (Mapping set in
084: * associated BeanInfo class.)
085: */
086: private String styleExpr;
087:
088: /**
089: * Instance variable mapped to "styleClass" tag attribute. (Mapping set in
090: * associated BeanInfo class.)
091: */
092: private String styleClassExpr;
093:
094: /**
095: * Instance variable mapped to "styleId" tag attribute. (Mapping set in
096: * associated BeanInfo class.)
097: */
098: private String styleIdExpr;
099:
100: /**
101: * Instance variable mapped to "value" tag attribute. (Mapping set in
102: * associated BeanInfo class.)
103: */
104: private String valueExpr;
105:
106: /**
107: * Getter method for "bundle" tag attribute. (Mapping set in associated
108: * BeanInfo class.)
109: */
110: public String getBundleExpr() {
111: return (bundleExpr);
112: }
113:
114: /**
115: * Getter method for "dir" tag attribute. (Mapping set in associated
116: * BeanInfo class.)
117: */
118: public String getDirExpr() {
119: return (dirExpr);
120: }
121:
122: /**
123: * Getter method for "disabled" tag attribute. (Mapping set in associated
124: * BeanInfo class.)
125: */
126: public String getDisabledExpr() {
127: return (disabledExpr);
128: }
129:
130: /**
131: * Getter method for "filter" tag attribute. (Mapping set in associated
132: * BeanInfo class.)
133: */
134: public String getFilterExpr() {
135: return (filterExpr);
136: }
137:
138: /**
139: * Getter method for "lang" tag attribute. (Mapping set in associated
140: * BeanInfo class.)
141: */
142: public String getLangExpr() {
143: return (langExpr);
144: }
145:
146: /**
147: * Getter method for "key" tag attribute. (Mapping set in associated
148: * BeanInfo class.)
149: */
150: public String getKeyExpr() {
151: return (keyExpr);
152: }
153:
154: /**
155: * Getter method for "locale" tag attribute. (Mapping set in associated
156: * BeanInfo class.)
157: */
158: public String getLocaleExpr() {
159: return (localeExpr);
160: }
161:
162: /**
163: * Getter method for "style" tag attribute. (Mapping set in associated
164: * BeanInfo class.)
165: */
166: public String getStyleExpr() {
167: return (styleExpr);
168: }
169:
170: /**
171: * Getter method for "styleClass" tag attribute. (Mapping set in
172: * associated BeanInfo class.)
173: */
174: public String getStyleClassExpr() {
175: return (styleClassExpr);
176: }
177:
178: /**
179: * Getter method for "styleId" tag attribute. (Mapping set in associated
180: * BeanInfo class.)
181: */
182: public String getStyleIdExpr() {
183: return (styleIdExpr);
184: }
185:
186: /**
187: * Getter method for "value" tag attribute. (Mapping set in associated
188: * BeanInfo class.)
189: */
190: public String getValueExpr() {
191: return (valueExpr);
192: }
193:
194: /**
195: * Setter method for "bundle" tag attribute. (Mapping set in associated
196: * BeanInfo class.)
197: */
198: public void setBundleExpr(String bundleExpr) {
199: this .bundleExpr = bundleExpr;
200: }
201:
202: /**
203: * Setter method for "dir" tag attribute. (Mapping set in associated
204: * BeanInfo class.)
205: */
206: public void setDirExpr(String dirExpr) {
207: this .dirExpr = dirExpr;
208: }
209:
210: /**
211: * Setter method for "disabled" tag attribute. (Mapping set in associated
212: * BeanInfo class.)
213: */
214: public void setDisabledExpr(String disabledExpr) {
215: this .disabledExpr = disabledExpr;
216: }
217:
218: /**
219: * Setter method for "filter" tag attribute. (Mapping set in associated
220: * BeanInfo class.)
221: */
222: public void setFilterExpr(String filterExpr) {
223: this .filterExpr = filterExpr;
224: }
225:
226: /**
227: * Setter method for "key" tag attribute. (Mapping set in associated
228: * BeanInfo class.)
229: */
230: public void setKeyExpr(String keyExpr) {
231: this .keyExpr = keyExpr;
232: }
233:
234: /**
235: * Setter method for "lang" tag attribute. (Mapping set in associated
236: * BeanInfo class.)
237: */
238: public void setLangExpr(String langExpr) {
239: this .langExpr = langExpr;
240: }
241:
242: /**
243: * Setter method for "locale" tag attribute. (Mapping set in associated
244: * BeanInfo class.)
245: */
246: public void setLocaleExpr(String localeExpr) {
247: this .localeExpr = localeExpr;
248: }
249:
250: /**
251: * Setter method for "style" tag attribute. (Mapping set in associated
252: * BeanInfo class.)
253: */
254: public void setStyleExpr(String styleExpr) {
255: this .styleExpr = styleExpr;
256: }
257:
258: /**
259: * Setter method for "styleClass" tag attribute. (Mapping set in
260: * associated BeanInfo class.)
261: */
262: public void setStyleClassExpr(String styleClassExpr) {
263: this .styleClassExpr = styleClassExpr;
264: }
265:
266: /**
267: * Setter method for "styleId" tag attribute. (Mapping set in associated
268: * BeanInfo class.)
269: */
270: public void setStyleIdExpr(String styleIdExpr) {
271: this .styleIdExpr = styleIdExpr;
272: }
273:
274: /**
275: * Setter method for "value" tag attribute. (Mapping set in associated
276: * BeanInfo class.)
277: */
278: public void setValueExpr(String valueExpr) {
279: this .valueExpr = valueExpr;
280: }
281:
282: /**
283: * Resets attribute values for tag reuse.
284: */
285: public void release() {
286: super .release();
287: setBundleExpr(null);
288: setDirExpr(null);
289: setDisabledExpr(null);
290: setFilterExpr(null);
291: setLangExpr(null);
292: setKeyExpr(null);
293: setLocaleExpr(null);
294: setStyleExpr(null);
295: setStyleClassExpr(null);
296: setStyleIdExpr(null);
297: setValueExpr(null);
298: }
299:
300: /**
301: * Process the start tag.
302: *
303: * @throws JspException if a JSP exception has occurred
304: */
305: public int doStartTag() throws JspException {
306: evaluateExpressions();
307:
308: return (super .doStartTag());
309: }
310:
311: /**
312: * Processes all attribute values which use the JSTL expression evaluation
313: * engine to determine their values.
314: *
315: * @throws JspException if a JSP exception has occurred
316: */
317: private void evaluateExpressions() throws JspException {
318: String string = null;
319: Boolean bool = null;
320:
321: if ((string = EvalHelper.evalString("bundle", getBundleExpr(),
322: this , pageContext)) != null) {
323: setBundle(string);
324: }
325:
326: if ((string = EvalHelper.evalString("dir", getDirExpr(), this ,
327: pageContext)) != null) {
328: setDir(string);
329: }
330:
331: if ((bool = EvalHelper.evalBoolean("disabled",
332: getDisabledExpr(), this , pageContext)) != null) {
333: setDisabled(bool.booleanValue());
334: }
335:
336: if ((bool = EvalHelper.evalBoolean("filter", getFilterExpr(),
337: this , pageContext)) != null) {
338: setFilter(bool.booleanValue());
339: }
340:
341: if ((string = EvalHelper.evalString("lang", getLangExpr(),
342: this , pageContext)) != null) {
343: setLang(string);
344: }
345:
346: if ((string = EvalHelper.evalString("key", getKeyExpr(), this ,
347: pageContext)) != null) {
348: setKey(string);
349: }
350:
351: if ((string = EvalHelper.evalString("locale", getLocaleExpr(),
352: this , pageContext)) != null) {
353: setLocale(string);
354: }
355:
356: if ((string = EvalHelper.evalString("style", getStyleExpr(),
357: this , pageContext)) != null) {
358: setStyle(string);
359: }
360:
361: if ((string = EvalHelper.evalString("styleClass",
362: getStyleClassExpr(), this , pageContext)) != null) {
363: setStyleClass(string);
364: }
365:
366: if ((string = EvalHelper.evalString("styleId",
367: getStyleIdExpr(), this , pageContext)) != null) {
368: setStyleId(string);
369: }
370:
371: if ((string = EvalHelper.evalString("value", getValueExpr(),
372: this, pageContext)) != null) {
373: setValue(string);
374: }
375: }
376: }
|