package com.avantouch.common.web.struts.taglib.table;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
/**
* <p>Title TableBase.java</p>
* <p>Description </p>
* <p>Copyright: Copyright (c) 2004 AvanTouch,Inc</p>
* <p>Company: AvanTouch,Inc</p>
* @author: david 2004-12-6
* @modifier:
* @version 1.0
*/
public abstract class TableBase extends BodyTagSupport {
public static final String[] DirValue = { "ltr", "rtl" };
/**
* The identifier associated with this tag.
*/
protected String styleId = null;
protected String align = "left";
protected String bgcolor = null;
protected String bordercolor = null;
protected String bordercolordark = null;
protected String bordercolorlight = null;
protected String dir = null;
/**
* The style class associated with this tag.
*/
protected String styleClass = null;
protected String height = null;
protected String lang = null;
protected String title = null;
protected String style = null;
// Mouse Events
/** Mouse click event. */
private String onClick_T = null;
/** Mouse double click event. */
private String onDblClick_T = null;
/** Mouse over component event. */
private String onMouseOver_T = null;
/** Mouse exit component event. */
private String onMouseOut_T = null;
/** Mouse moved over component event. */
private String onMouseMove_T = null;
/** Mouse pressed on component event. */
private String onMouseDown_T = null;
/** Mouse released on component event. */
private String onMouseUp_T = null;
// Keyboard Events
/** Key down in component event. */
private String onKeyDown_T = null;
/** Key released in component event. */
private String onKeyUp_T = null;
/** Key down and up together in component event. */
private String onKeyPress_T = null;
// Mouse Events
/** Sets the onClick event handler. */
public void setOnClick_T(String onClick) {
this.onClick_T = onClick;
}
/** Returns the onClick event handler. */
public String getOnClick_T() {
return onClick_T;
}
/** Sets the onDblClick event handler. */
public void setOnDblClick_T(String onDblClick) {
this.onDblClick_T = onDblClick;
}
/** Returns the onDblClick event handler. */
public String getOnDblClick_T() {
return onDblClick_T;
}
/** Sets the onMouseDown event handler. */
public void setOnMouseDown_T(String onMouseDown) {
this.onMouseDown_T = onMouseDown;
}
/** Returns the onMouseDown event handler. */
public String getOnMouseDown_T() {
return onMouseDown_T;
}
/** Sets the onMouseUp event handler. */
public void setOnMouseUp_T(String onMouseUp) {
this.onMouseUp_T = onMouseUp;
}
/** Returns the onMouseUp event handler. */
public String getOnMouseUp_T() {
return onMouseUp_T;
}
/** Sets the onMouseMove event handler. */
public void setOnMouseMove_T(String onMouseMove) {
this.onMouseMove_T = onMouseMove;
}
/** Returns the onMouseMove event handler. */
public String getOnMouseMove_T() {
return onMouseMove_T;
}
/** Sets the onMouseOver event handler. */
public void setOnMouseOver_T(String onMouseOver) {
this.onMouseOver_T = onMouseOver;
}
/** Returns the onMouseOver event handler. */
public String getOnMouseOver_T() {
return onMouseOver_T;
}
/** Sets the onMouseOut event handler. */
public void setOnMouseOut_T(String onMouseOut) {
this.onMouseOut_T = onMouseOut;
}
/** Returns the onMouseOut event handler. */
public String getOnMouseOut_T() {
return onMouseOut_T;
}
// Keyboard Events
/** Sets the onKeyDown event handler. */
public void setOnKeyDown_T(String onKeyDown) {
this.onKeyDown_T = onKeyDown;
}
/** Returns the onKeyDown event handler. */
public String getOnKeyDown_T() {
return onKeyDown_T;
}
/** Sets the onKeyUp event handler. */
public void setOnKeyUp_T(String onKeyUp) {
this.onKeyUp_T = onKeyUp;
}
/** Returns the onKeyUp event handler. */
public String getOnKeyUp_T() {
return onKeyUp_T;
}
/** Sets the onKeyPress event handler. */
public void setOnKeyPress_T(String onKeyPress) {
this.onKeyPress_T = onKeyPress;
}
/** Returns the onKeyPress event handler. */
public String getOnKeyPress_T() {
return onKeyPress_T;
}
/**
* set identifier for table or tr or td
* p><code>setT_ID</code></p>
* @param handlers
* @author david 2004-12-6
* @Since 1.0
*/
public void setT_ID(StringBuffer handlers){
if(styleId!=null&&!styleId.trim().equals("")){
handlers.append(" ID=/"");
handlers.append(styleId);
handlers.append("/"");
}
}// end setT_ID
/**
* Prepares the mouse event handlers, appending them to the the given
* StringBuffer.
* @param handlers The StringBuffer that output will be appended to.
*/
public void prepareMouseEvents_T(StringBuffer handlers) {
if (onClick_T != null) {
handlers.append(" onClick=/"");
handlers.append(getOnClick_T());
handlers.append("/"");
}
if (onDblClick_T != null) {
handlers.append(" onDblclick=/"");
handlers.append(getOnDblClick_T());
handlers.append("/"");
}
if (onMouseOver_T != null) {
handlers.append(" onMouseOver=/"");
handlers.append(getOnMouseOver_T());
handlers.append("/"");
}
if (onMouseOut_T != null) {
handlers.append(" onMouseOut=/"");
handlers.append(getOnMouseOut_T());
handlers.append("/"");
}
if (onMouseMove_T != null) {
handlers.append(" onMouseMove=/"");
handlers.append(getOnMouseMove_T());
handlers.append("/"");
}
if (onMouseDown_T != null) {
handlers.append(" onMouseDown=/"");
handlers.append(getOnMouseDown_T());
handlers.append("/"");
}
if (onMouseUp_T != null) {
handlers.append(" onMouseUp=/"");
handlers.append(getOnMouseUp_T());
handlers.append("/"");
}
} // end prepareMouseEvents_T
/**
* Prepares the keyboard event handlers, appending them to the the given
* StringBuffer.
* @param handlers The StringBuffer that output will be appended to.
*/
public void prepareKeyEvents_T(StringBuffer handlers) {
if (onKeyDown_T != null) {
handlers.append(" onKeyDown=/"");
handlers.append(getOnKeyDown_T());
handlers.append("/"");
}
if (onKeyUp_T != null) {
handlers.append(" onKeyUp=/"");
handlers.append(getOnKeyUp_T());
handlers.append("/"");
}
if (onKeyPress_T != null) {
handlers.append(" onKeyPress=/"");
handlers.append(getOnKeyPress_T());
handlers.append("/"");
}
} // end prepareKeyEvents_T
/**
* Prepares all event handlers, appending them to the the given StringBuffer.
* <p><code>prepareEvents_T</code></p>
* @param handlers
* @author david 2004-12-6
* @Since 1.0
*/
public void prepareEvents_T(StringBuffer handlers) {
prepareKeyEvents_T(handlers);
prepareMouseEvents_T(handlers);
} // end prepareEvents_T
/**
* set common attributes value
* p><code>setT_CommonAttributes</code></p>
* @param handlers
* @author david 2004-12-6
* @Since 1.0
*/
public void setT_CommonAttributes(StringBuffer handlers) {
if(!align.trim().equals("")&&!align.trim().equalsIgnoreCase("left")){
handlers.append(" ALIGN=/"" + align + "/"");
}
if (bgcolor != null && !bgcolor.trim().equals("")) {
handlers.append(" BGCOLOR=/"" + bgcolor + "/"");
}
if (bordercolor != null && !bordercolor.trim().equals("")) {
handlers.append(" BORDERCOLOR=/"" + bordercolor + "/"");
}
if (bordercolordark != null && !bordercolordark.trim().equals("")) {
handlers.append(" BORDERCOLORDARK=/"" + bordercolordark + "/"");
}
if (bordercolorlight != null && !bordercolorlight.trim().equals("")) {
handlers.append(" BORDERCOLORLIGHT=/"" + bordercolorlight + "/"");
}
if (dir != null && !dir.trim().equals("")) {
handlers.append(" DIR=/"" + dir + "/"");
}
if (styleClass != null && !styleClass.trim().equals("")) {
handlers.append(" CLASS=/"" + styleClass + "/"");
}
if (lang != null && !lang.trim().equals("")) {
handlers.append(" LANG=/"" + lang + "/"");
}
if (style != null && !style.trim().equals("")) {
handlers.append(" STYLE=/"" + style + "/"");
}
if (height != null && !height.trim().equals("")) {
handlers.append(" HEIGHT=/"" + height + "/"");
}
} // end setT_CommonAttributes
public String getAlign() {
return align;
}
public void setAlign(String align) {
this.align = align;
}
public String getBgcolor() {
return bgcolor;
}
public void setBgcolor(String bgcolor) {
this.bgcolor = bgcolor;
}
public String getBordercolor() {
return bordercolor;
}
public void setBordercolor(String bordercolor) {
this.bordercolor = bordercolor;
}
public String getBordercolordark() {
return bordercolordark;
}
public void setBordercolordark(String bordercolordark) {
this.bordercolordark = bordercolordark;
}
public String getBordercolorlight() {
return bordercolorlight;
}
public void setBordercolorlight(String bordercolorlight) {
this.bordercolorlight = bordercolorlight;
}
public String getDir() {
return dir;
}
public void setDir(String dir) {
this.dir = dir;
}
public String getHeight() {
return height;
}
public void setHeight(String height) {
this.height = height;
}
public String getLang() {
return lang;
}
public void setLang(String lang) {
this.lang = lang;
}
public String getStyle() {
return style;
}
public void setStyle(String style) {
this.style = style;
}
public String getStyleClass() {
return styleClass;
}
public void setStyleClass(String styleClass) {
this.styleClass = styleClass;
}
public String getStyleId() {
return styleId;
}
public void setStyleId(String styleId) {
this.styleId = styleId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
/**
* validate dir's value
* <p><code>validateDir</code></p>
* @throws JspException
* @author david 2004-12-1
* @Since 1.0
*/
public void validateDir() throws JspException {
if (dir == null || dir.trim().equals("")) {
return;
}
int i = 0;
for (; i < DirValue.length; i++) {
if (dir.equalsIgnoreCase(DirValue[i]))
break;
}
if (i >= DirValue.length) {
throw new JspException(dir + ":Dir's value is lawless(ltr,rtl)!");
}
} // end validateDir
/**
* Release all allocated resources.
*/
public void release() {
super.release();
style = null;
height = null;
align = "left";
styleClass = null;
styleId = null;
bgcolor = null;
bordercolor = null;
bordercolordark = null;
bordercolorlight = null;
lang = null;
title = null;
dir = null;
onClick_T = null;
onDblClick_T = null;
onKeyDown_T = null;
onKeyPress_T = null;
onKeyUp_T = null;
onMouseDown_T = null;
onMouseMove_T = null;
onMouseOut_T = null;
onMouseOver_T = null;
onMouseUp_T = null;
} // end release
public int doEndTag() throws JspException {
release();
// Continue processing this page
return (EVAL_PAGE);
}
} // end TableBase