01: /*
02: * Copyright 2005-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
05: * in compliance with the License. You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software distributed under the License
10: * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11: * or implied. See the License for the specific language governing permissions and limitations under
12: * the License.
13: */
14:
15: package org.strecks.web.tag;
16:
17: import javax.servlet.jsp.JspException;
18: import javax.servlet.jsp.PageContext;
19: import javax.servlet.jsp.tagext.TagSupport;
20:
21: import org.apache.commons.logging.Log;
22: import org.apache.commons.logging.LogFactory;
23:
24: /**
25: * Base tag which allows variable in page context to be used to expose an attribute associated with
26: * the current request
27: *
28: * @author Phil Zoio
29: */
30: public abstract class ExposeRequestAttributeTag extends TagSupport {
31:
32: Log log = LogFactory.getLog(ExposeRequestAttributeTag.class);
33:
34: protected abstract String getRequestAttributeName();
35:
36: /**
37: * the name of the page attribute which will hold the exposed value
38: */
39: private String var;
40:
41: // ------------------------------------------------------- Public Methods
42:
43: public int doStartTag() throws JspException {
44:
45: Object attribute = pageContext.getAttribute(
46: getRequestAttributeName(), PageContext.REQUEST_SCOPE);
47: pageContext.setAttribute(var, attribute);
48: return (SKIP_BODY);
49:
50: }
51:
52: /**
53: * Release any acquired resources.
54: */
55: public void release() {
56: super .release();
57: var = null;
58: }
59:
60: /* ****** getters and setters ******* */
61:
62: public void setVar(String var) {
63: this.var = var;
64: }
65:
66: }
|