package com.avantouch.common.web.struts.taglib;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.ResponseUtils;
/**
* <p>Title ColumndeleteTag.java</p>
* <p>Description </p>
* <p>Copyright: Copyright (c) 2004 AvanTouch,Inc</p>
* <p>Company: AvanTouch,Inc</p>
* @author: david 2004-12-7
* @modifier:
* @version 1.0
*/
public class ColumndeleteTag extends ContentBase {
private static final long serialVersionUID = 1L;
private String link = null;
private String name = null;
private String key = null;
private String method = "delete";
/**
* The scope of the bean specified by the name property, if any.
*/
protected String scope = null;
public int doStartTag() throws JspException {
setAlign("center");
writeTDHeaders();
writeHyperlink();
return (SKIP_BODY);
}
public int doEndTag() throws JspException {
writeTDEnd();
release();
// Continue processing this page
return (EVAL_PAGE);
}
/**
* write hyperlink
* p><code>writeHyperlink</code></p>
* @throws JspException
* @author david 2004-12-7
* @Since 1.0
*/
public void writeHyperlink() throws JspException {
String prefixPath = ((HttpServletRequest) pageContext.getRequest()).getContextPath();
Object value = null;
if (name != null) {
value = RequestUtils.lookup(pageContext, name, key, scope);
} else {
value = key;
}
link = link + "?method=" + method + "&key=" + value;
StringBuffer buf = new StringBuffer("<A");
buf.append(" href=/"" + link + "/"");
if (getTitle() != null) {
buf.append(" TITLE=/"" + getTitle() + "/"");
} else {
buf.append(" TITLE=/"delete this record/"");
}
prepareEvents(buf);
buf.append(">");
buf.append("<img width='16' height='16' border='0' src='" + prefixPath + "/images/buttons/delete.gif'>");
buf.append("</A>");
ResponseUtils.write(pageContext, buf.toString());
} // end writeHyperlink
/**
* Release all allocated resources.
*/
public void release() {
super.release();
link = null;
name = null;
key = null;
scope = null;
}
public String getLink() {
return link;
}
public String getName() {
return name;
}
public String getKey() {
return key;
}
public void setName(String name) {
this.name = name;
}
public void setKey(String property) {
this.key = property;
}
public String getScope() {
return scope;
}
public void setLink(String action) {
this.link = action;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getMethod() {
return method;
}
public void setMethod(String string) {
method = string;
}
}