01: /*
02: * Copyright 2004, 2005, 2006 Odysseus Software GmbH
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package de.odysseus.calyxo.base.taglib;
17:
18: import javax.servlet.http.HttpServletRequest;
19: import javax.servlet.jsp.JspException;
20: import javax.servlet.jsp.tagext.TagSupport;
21:
22: import de.odysseus.calyxo.base.ModuleContext;
23: import de.odysseus.calyxo.base.ModuleSupport;
24: import de.odysseus.calyxo.base.access.AccessSupport;
25:
26: /**
27: * This tag exports an accessor from module scope into request scope.
28: * The module's <code>AccessSupport</code> is used to get the accessor.
29: *
30: * @author Christoph Beck
31: */
32: public class AccessTag extends TagSupport {
33: private String var;
34:
35: public int doEndTag() throws JspException {
36: ModuleSupport modules = ModuleSupport.getInstance(pageContext);
37: ModuleContext context = modules.getModuleContext(pageContext);
38: HttpServletRequest request = (HttpServletRequest) pageContext
39: .getRequest();
40:
41: AccessSupport support = AccessSupport.getInstance(context);
42: request.setAttribute(var, support.create(request));
43:
44: reset();
45: return EVAL_PAGE;
46: }
47:
48: /*
49: * (non-Javadoc)
50: * @see javax.servlet.jsp.tagext.Tag#release()
51: */
52: public void release() {
53: reset();
54: }
55:
56: /**
57: * Reset properties
58: */
59: protected void reset() {
60: var = null;
61: }
62:
63: /**
64: * Get the var attribute
65: */
66: public String getVar() {
67: return var;
68: }
69:
70: /**
71: * Set the var attribute
72: */
73: public void setVar(String string) {
74: var = string;
75: }
76:
77: }
|