struts taglib 源码之--BaseHandlerTag

BaseHandlerTag是处理标签事件和style,title等基本属性的抽象类.具体的标签类继承于此类,添加额外属性.源码如下(jakarta-struts-1.0.2):
package  org.apache.struts.taglib.html;

import  javax.servlet.jsp.tagext.BodyTagSupport;
import  org.apache.struts.util.MessageResources;

public   abstract   class  BaseHandlerTag  extends  BodyTagSupport
{

    
protected static MessageResources messages = MessageResources.getMessageResources("org.apache.struts.taglib.html.LocalStrings");
    
protected String accesskey;
    
protected String tabindex;
    
private String onclick;
    
private String ondblclick;
    
private String onmouseover;
    
private String onmouseout;
    
private String onmousemove;
    
private String onmousedown;
    
private String onmouseup;
    
private String onkeydown;
    
private String onkeyup;
    
private String onkeypress;
    
private String onselect;
    
private String onchange;
    
private String onblur;
    
private String onfocus;
    
private boolean disabled;
    
private boolean readonly;
    
private String style;
    
private String styleClass;
    
private String styleId;
    
private String title;

    
public BaseHandlerTag()
    
{
        accesskey 
= null;
        tabindex 
= null;
        onclick 
= null;
        ondblclick 
= null;
        onmouseover 
= null;
        onmouseout 
= null;
        onmousemove 
= null;
        onmousedown 
= null;
        onmouseup 
= null;
        onkeydown 
= null;
        onkeyup 
= null;
        onkeypress 
= null;
        onselect 
= null;
        onchange 
= null;
        onblur 
= null;
        onfocus 
= null;
        disabled 
= false;
        readonly 
= false;
        style 
= null;
        styleClass 
= null;
        styleId 
= null;
        title 
= null;
    }


    
public void setAccesskey(String accessKey)
    
{
        accesskey 
= accessKey;
    }


    
public String getAccesskey()
    
{
        
return accesskey;
    }


    
public void setTabindex(String tabIndex)
    
{
        tabindex 
= tabIndex;
    }


    
public String getTabindex()
    
{
        
return tabindex;
    }


    
public void setOnclick(String onClick)
    
{
        onclick 
= onClick;
    }


    
public String getOnclick()
    
{
        
return onclick;
    }


    
public void setOndblclick(String onDblClick)
    
{
        ondblclick 
= onDblClick;
    }


    
public String getOndblclick()
    
{
        
return ondblclick;
    }


    
public void setOnmousedown(String onMouseDown)
    
{
        onmousedown 
= onMouseDown;
    }


    
public String getOnmousedown()
    
{
        
return onmousedown;
    }


    
public void setOnmouseup(String onMouseUp)
    
{
        onmouseup 
= onMouseUp;
    }


    
public String getOnmouseup()
    
{
        
return onmouseup;
    }


    
public void setOnmousemove(String onMouseMove)
    
{
        onmousemove 
= onMouseMove;
    }


    
public String getOnmousemove()
    
{
        
return onmousemove;
    }


    
public void setOnmouseover(String onMouseOver)
    
{
        onmouseover 
= onMouseOver;
    }


    
public String getOnmouseover()
    
{
        
return onmouseover;
    }


    
public void setOnmouseout(String onMouseOut)
    
{
        onmouseout 
= onMouseOut;
    }


    
public String getOnmouseout()
    
{
        
return onmouseout;
    }


    
public void setOnkeydown(String onKeyDown)
    
{
        onkeydown 
= onKeyDown;
    }


    
public String getOnkeydown()
    
{
        
return onkeydown;
    }


    
public void setOnkeyup(String onKeyUp)
    
{
        onkeyup 
= onKeyUp;
    }


    
public String getOnkeyup()
    
{
        
return onkeyup;
    }


    
public void setOnkeypress(String onKeyPress)
    
{
        onkeypress 
= onKeyPress;
    }


    
public String getOnkeypress()
    
{
        
return onkeypress;
    }


    
public void setOnchange(String onChange)
    
{
        onchange 
= onChange;
    }


    
public String getOnchange()
    
{
        
return onchange;
    }


    
public void setOnselect(String onSelect)
    
{
        onselect 
= onSelect;
    }


    
public String getOnselect()
    
{
        
return onselect;
    }


    
public void setOnblur(String onBlur)
    
{
        onblur 
= onBlur;
    }


    
public String getOnblur()
    
{
        
return onblur;
    }


    
public void setOnfocus(String onFocus)
    
{
        onfocus 
= onFocus;
    }


    
public String getOnfocus()
    
{
        
return onfocus;
    }


    
public void setDisabled(boolean disabled)
    
{
        
this.disabled = disabled;
    }


    
public boolean getDisabled()
    
{
        
return disabled;
    }


    
public void setReadonly(boolean readonly)
    
{
        
this.readonly = readonly;
    }


    
public boolean getReadonly()
    
{
        
return readonly;
    }


    
public void setStyle(String style)
    
{
        
this.style = style;
    }


    
public String getStyle()
    
{
        
return style;
    }


    
public void setStyleClass(String styleClass)
    
{
        
this.styleClass = styleClass;
    }


    
public String getStyleClass()
    
{
        
return styleClass;
    }


    
public void setStyleId(String styleId)
    
{
        
this.styleId = styleId;
    }


    
public String getStyleId()
    
{
        
return styleId;
    }


    
public String getTitle()
    
{
        
return title;
    }


    
public void setTitle(String title)
    
{
        
this.title = title;
    }


    
public void release()
    
{
        
super.release();
        accesskey 
= null;
        tabindex 
= null;
        onclick 
= null;
        ondblclick 
= null;
        onmouseover 
= null;
        onmouseout 
= null;
        onmousemove 
= null;
        onmousedown 
= null;
        onmouseup 
= null;
        onkeydown 
= null;
        onkeyup 
= null;
        onkeypress 
= null;
        onselect 
= null;
        onchange 
= null;
        onblur 
= null;
        onfocus 
= null;
        disabled 
= false;
        readonly 
= false;
        style 
= null;
        styleClass 
= null;
        styleId 
= null;
        title 
= null;
    }


    
protected String prepareStyles()
    
{
        StringBuffer styles 
= new StringBuffer();
        
if(style != null)
        
{
            styles.append(
" style="");
            styles.append(style);
            styles.append(
""");
        }

        
if(styleClass != null)
        
{
            styles.append(
" class="");
            styles.append(styleClass);
            styles.append(
""");
        }

        
if(styleId != null)
        
{
            styles.append(
" id="");
            styles.append(styleId);
            styles.append(
""");
        }

        
if(title != null)
        
{
            styles.append(
" title="");
            styles.append(title);
            styles.append(
""");
        }

        
return styles.toString();
    }


    
protected String prepareEventHandlers()
    
{
        StringBuffer handlers 
= new StringBuffer();
        prepareMouseEvents(handlers);
        prepareKeyEvents(handlers);
        prepareTextEvents(handlers);
        prepareFocusEvents(handlers);
        
return handlers.toString();
    }


    
private void prepareMouseEvents(StringBuffer handlers)
    
{
        
if(onclick != null)
        
{
            handlers.append(
" οnclick="");
            handlers.append(onclick);
            handlers.append(
""");
        }

        
if(ondblclick != null)
        
{
            handlers.append(
" οndblclick="");
            handlers.append(ondblclick);
            handlers.append(
""");
        }

        
if(onmouseover != null)
        
{
            handlers.append(
" οnmοuseοver="");
            handlers.append(onmouseover);
            handlers.append(
""");
        }

        
if(onmouseout != null)
        
{
            handlers.append(
" οnmοuseοut="");
            handlers.append(onmouseout);
            handlers.append(
""");
        }

        
if(onmousemove != null)
        
{
            handlers.append(
" οnmοusemοve="");
            handlers.append(onmousemove);
            handlers.append(
""");
        }

        
if(onmousedown != null)
        
{
            handlers.append(
" οnmοusedοwn="");
            handlers.append(onmousedown);
            handlers.append(
""");
        }

        
if(onmouseup != null)
        
{
            handlers.append(
" οnmοuseup="");
            handlers.append(onmouseup);
            handlers.append(
""");
        }

    }


    
private void prepareKeyEvents(StringBuffer handlers)
    
{
        
if(onkeydown != null)
        
{
            handlers.append(
" οnkeydοwn="");
            handlers.append(onkeydown);
            handlers.append(
""");
        }

        
if(onkeyup != null)
        
{
            handlers.append(
" οnkeyup="");
            handlers.append(onkeyup);
            handlers.append(
""");
        }

        
if(onkeypress != null)
        
{
            handlers.append(
" οnkeypress="");
            handlers.append(onkeypress);
            handlers.append(
""");
        }

    }


    
private void prepareTextEvents(StringBuffer handlers)
    
{
        
if(onselect != null)
        
{
            handlers.append(
" οnselect="");
            handlers.append(onselect);
            handlers.append(
""");
        }

        
if(onchange != null)
        
{
            handlers.append(
" οnchange="");
            handlers.append(onchange);
            handlers.append(
""");
        }

    }


    
private void prepareFocusEvents(StringBuffer handlers)
    
{
        
if(onblur != null)
        
{
            handlers.append(
" οnblur="");
            handlers.append(onblur);
            handlers.append(
""");
        }

        
if(onfocus != null)
        
{
            handlers.append(
" οnfοcus="");
            handlers.append(onfocus);
            handlers.append(
""");
        }

        
if(disabled)
            handlers.append(
" disabled="disabled"");
        
if(readonly)
            handlers.append(
" readonly="readonly"");
    }


}
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值