Package com.avantouch.common.web.struts.taglib.table;
Import javax.servlet.jsp.JspException;
Import Org.apache.struts.util.ResponseUtils;
/**
* <p>title tabletag.java</p>
* <p>description </p>
* <p>copyright:copyright (c) avantouch,inc</p>
* <p>Company:AvanTouch,Inc</p>
* @author: David 2004-12-6
* @modifier:
* @version 1.0
*/
public class Tabletag extends Tablebase {
public static final string[] Framevalue =
{
"Above",
"Below",
"Border",
"Box",
"Hsides",
"LHS",
"RHS",
"Void",
"Vsides"};
public static final string[] Rulesvalue =
{"All", "cors", "groups", "none", "Rows"};
Private String backgroud = null;
Private String border = null;
Private String cellpadding = null;
Private String cellspacing = null;
Private String cols = null;
Private String datapagesize = null;
Private String frame = null;
Private String rules = NULL;
Private String vspace = null;
Private String hspace = null;
Private String summary = null;
Private String caption = null;
Private String width = "65%";
/**
* Styleclass1_tr and styleclass2_tr associated with TR tag
*/
Private String styleclass1_tr = null;
Private String styleclass2_tr = null;
/**
* Set TD Common attributes value
* <p><code>setTableCommonAttributes</code></p>
* @param handlers
* @author David 2004-12-6
* @Since 1.0
*/
public void Settablecommonattributes (StringBuffer handlers) {
if (Border!= null &&!border.trim (). Equals ("")) {
Handlers.append ("border=/" "+ BORDER +"/");
}
if (cellpadding!= null &&!cellpadding.trim (). Equals ("")) {
Handlers.append ("cellpadding=/" "+ cellpadding +"/");
}
if (cellspacing!= null &&!cellspacing.trim (). Equals ("")) {
Handlers.append ("cellspacing=/" "+ cellspacing +"/");
}
if (width!= null &&!width.trim (). Equals ("")) {
Handlers.append ("width=/" "+ WIDTH +"/");
}
Sett_commonattributes (handlers);
if (backgroud!= null &&!backgroud.trim (). Equals ("")) {
Handlers.append ("backgroud=/" "+ Backgroud +"/");
}
if (cols!= null &&!cols.trim (). Equals ("")) {
Handlers.append ("cols=/" "+ COLS +"/");
}
if (datapagesize!= null &&!datapagesize.trim (). Equals ("")) {
Handlers.append ("datapagesize=/" "+ datapagesize +"/");
}
if (frame!= null &&!frame.trim (). Equals ("")) {
Handlers.append ("frame=/" "+ FRAME +"/");
}
if (summary!= null &&!summary.trim (). Equals ("")) {
Handlers.append ("summary=/" "+ SUMMARY +"/");
}
if (vspace!= null &&!vspace.trim (). Equals ("")) {
Handlers.append ("vspace=/" "+ vspace +"/");
}
if (hspace!= null &&!hspace.trim (). Equals ("")) {
Handlers.append ("hspace=/" "+ hspace +"/");
}
if (rules!= null &&!rules.trim (). Equals ()) {
Handlers.append ("rules=/" "+ RULES +"/");
}
}//End Settablecommonattributes
/**
* Set Table Caption
* <p><code>setTableCaption</code></p>
* @param buffer
* @return
* @author David 2004-12-6
* @Since 1.0
*/
Public StringBuffer settablecaption (stringbuffer buffer) {
StringBuffer buf = buffer;
if (caption!= null &&!caption.trim (). Equals ("")) {
Buf.append ("<CAPTION><EM>" + CAPTION + "</em></caption>/n");
}
return buf;
}//End Settablecaption
public int doStartTag () throws Jspexception {
Validateframe ();
Validatedir ();
Validaterules ();
StringBuffer buf = new StringBuffer ("<table");
SETT_ID (BUF);
Settablecommonattributes (BUF);
prepareevents_t (BUF);
Buf.append (">/n");
Settablecaption (BUF);
Responseutils.write (PageContext, buf.tostring ());
if (styleclass1_tr!= null
&& styleclass2_tr!= NULL
&&!styleclass1_tr.trim (). Equals ("")
&&!styleclass2_tr.trim (). Equals ("")) {
Pagecontext.setattribute ("TRCALSS1", styleclass1_tr);
Pagecontext.setattribute ("TRCALSS2", styleclass2_tr);
Pagecontext.setattribute ("Currenttrclass", "0");
}
return (Eval_body_include);
}
public int Doendtag () throws Jspexception {
StringBuffer buf = new StringBuffer ("</table>/n");
Responseutils.write (PageContext, buf.tostring ());
Release ();
Continue processing this page
return (Eval_page);
}
/**
* Release of all allocated resources.
*/
public void release () {
Super.release ();
Backgroud = null;
border = null;
cellpadding = null;
cellspacing = null;
cols = null;
DataPageSize = null;
frame = null;
rules = NULL;
Vspace = null;
hspace = null;
Summary = null;
caption = null;
width = "65%";
STYLECLASS1_TR = null;
STYLECLASS2_TR = null;
if (styleclass1_tr!= null) {
Pagecontext.removeattribute ("TRCALSS1");
Pagecontext.removeattribute ("TRCALSS2");
Pagecontext.removeattribute ("Currenttrclass");
}
}//End release
Public String Getbackgroud () {
return backgroud;
}
public void Setbackgroud (String backgroud) {
This.backgroud = Backgroud;
}
Public String Getborder () {
return border;
}
public void SetBorder (String border) {
This.border = border;
}
Public String getcaption () {
return caption;
}
public void Setcaption (String caption) {
This.caption = caption;
}
Public String getcellpadding () {
return cellpadding;
}
public void setcellpadding (String cellpadding) {
this.cellpadding = cellpadding;
}
Public String getcellspacing () {
return cellspacing;
}
public void setcellspacing (String cellspacing) {
this.cellspacing = cellspacing;
}
Public String Getcols () {
return cols;
}
public void Setcols (String cols) {
This.cols = cols;
}
Public String getdatapagesize () {
return datapagesize;
}
public void Setdatapagesize (String datapagesize) {
This.datapagesize = datapagesize;
}
Public String GetFrame () {
return frame;
}
public void Setframe (String frame) {
This.frame = frame;
}
Public String Gethspace () {
return hspace;
}
public void Sethspace (String hspace) {
This.hspace = hspace;
}
Public String GetRules () {
return rules;
}
public void SetRules (String rules) {
This.rules = rules;
}
Public String getstyleclass1_tr () {
return styleclass1_tr;
}
public void Setstyleclass1_tr (String styleclass1_tr) {
THIS.STYLECLASS1_TR = STYLECLASS1_TR;
}
Public String getstyleclass2_tr () {
return styleclass2_tr;
}
public void Setstyleclass2_tr (String styleclass2_tr) {
THIS.STYLECLASS2_TR = STYLECLASS2_TR;
}
Public String getsummary () {
return summary;
}
public void Setsummary (String summary) {
This.summary = Summary;
}
Public String Getvspace () {
return vspace;
}
public void Setvspace (String vspace) {
This.vspace = vspace;
}
Public String getwidth () {
return width;
}
public void SetWidth (String width) {
This.width = width;
}
/**
* Validate Frame ' s value
* p><code>validateframe</code></p>
* @throws jspexception
* @author David 2004-12-1
* @Since 1.0
*/
public void Validateframe () throws Jspexception {
if frame = = NULL | | Frame.trim (). Equals ("")) {
Return
}
int i = 0;
for (; i < framevalue.length; i++) {
if (Frame.equalsignorecase (Framevalue[i]))
Break
}
if (i >= framevalue.length) {
throw New Jspexception (
Frame
+ ": Frame ' s value is lawless (above,below,border,box,hsides,lhs,rhs,void,vsides)!");
}
}//End Validateframe
/**
* Validate rules ' s value
* <p><code>validateRules</code> </p>
* @throws jspexception
* @author David 2004-12-1
* @Since 1.0
*/
&N bsp;public void Validaterules () throws Jspexception {
if (rules = = NULL | | Rules.trim (). Equals ("")) {
& nbsp; return;
}
int i = 0;
for (; i < rulesvalue.length; i++) {
if (rules.equalsignorecase (RulesValue[i) )
break;
}
if (i >= rulesvalue.length) {
throw new jspexception (
rules
+ ": Rules ' s value is lawless (all,cols,groups,none,rows)!");
}
}//End Validaterules
}//End Tabletag