/*
* Copyright 2004, 2005, 2006 Odysseus Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.odysseus.calyxo.base.taglib;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import de.odysseus.calyxo.base.ModuleContext;
import de.odysseus.calyxo.base.ModuleSupport;
import de.odysseus.calyxo.base.access.AccessSupport;
/**
* This tag exports an accessor from module scope into request scope.
* The module's <code>AccessSupport</code> is used to get the accessor.
*
* @author Christoph Beck
*/
public class AccessTag extends TagSupport {
private String var;
public int doEndTag() throws JspException {
ModuleSupport modules = ModuleSupport.getInstance(pageContext);
ModuleContext context = modules.getModuleContext(pageContext);
HttpServletRequest request =
(HttpServletRequest)pageContext.getRequest();
AccessSupport support = AccessSupport.getInstance(context);
request.setAttribute(var, support.create(request));
reset();
return EVAL_PAGE;
}
/*
* (non-Javadoc)
* @see javax.servlet.jsp.tagext.Tag#release()
*/
public void release() {
reset();
}
/**
* Reset properties
*/
protected void reset() {
var = null;
}
/**
* Get the var attribute
*/
public String getVar() {
return var;
}
/**
* Set the var attribute
*/
public void setVar(String string) {
var = string;
}
}