/*
* 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.panels.taglib;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import de.odysseus.calyxo.panels.misc.DynamicParamConfig;
/**
* Add a dynamic parameter to the enclosing panel tag.
*
* @author Christoph Beck
*/
public class ParamTag extends TagSupport {
private static final Log log = LogFactory.getLog(ParamTag.class);
private String name;
private Object value;
/**
* Add a dynamic parameter to the context's current panel.
*/
public int doEndTag() throws JspException {
if (log.isTraceEnabled())
log.trace("param " + name);
PanelTag panel = (PanelTag)findAncestorWithClass(this, PanelTag.class);
if (panel == null) {
throw new JspException("param tag must be nested in panel tag!");
}
panel.add(new DynamicParamConfig(name, value));
return EVAL_PAGE;
}
public void release() {
name = null;
value = null;
}
/**
* Get the param name
*/
public String getName() {
return name;
}
/**
* Set the param name
*/
public void setName(String string) {
name = string;
}
/**
* Get the param value
*/
public Object getValue() {
return value;
}
/**
* Set the param value
*/
public void setValue(Object object) {
value = object;
}
}