下面是本人参考该URL扩展了下displaytag的标签库:
http://jira.codehaus.org/browse/DISPL-187
需要修改的文件为图1.
首先, Displaytag.tld文件:
以给Column 添加鼠标经过事件:onmouseover
在tag name为column的标签下添加:
- < attribute >
- < name > onmouseover </ name >
- < required > false </ required >
- < rtexprvalue > true </ rtexprvalue >
- < type > java.lang.String </ type >
- < description >
- JavaScript onmouseover event attribute. add by lovejj.
- </ description >
- </ attribute >
<attribute> <name>onmouseover</name> <required>false</required> <rtexprvalue>true</rtexprvalue> <type>java.lang.String</type> <description> JavaScript onmouseover event attribute. add by lovejj. </description> </attribute>
其次:TagConstants.java文件:
添加标签属性:
- /**
- * html attribute <code>onmouseover</code>.
- */
- public static final String ATTRIBUTE_ONMOUSEOVER = "onmouseover" ; //lovejj
/**
* html attribute <code>onmouseover</code>.
*/
public static final String ATTRIBUTE_ONMOUSEOVER = "onmouseover"; //lovejj
再者: ColumnTag.java 文件:
添加set方法:
- /**
- * @author loveJJ
- * setter for the "onmouseout" tag attribute.
- * @param value attribute value
- */
- public void setOnmouseout(String value)
- {
- this .attributeMap.put(TagConstants.ATTRIBUTE_ONMOUSEOUT, value);
- }
/**
* @author loveJJ
* setter for the "onmouseout" tag attribute.
* @param value attribute value
*/
public void setOnmouseout(String value)
{
this.attributeMap.put(TagConstants.ATTRIBUTE_ONMOUSEOUT, value);
}
最后ColumnTagBeanInfo.java 文件:
添加页面标签描述符指向:
- //鼠标放上事件
- proplist.add( new PropertyDescriptor( "onmouseover" , //$NON-NLS-1$ add by lovejj
- ColumnTag. class ,
- null ,
- "setOnmouseover" )); //$NON-NLS-1$ add by lovejj
//鼠标放上事件
proplist.add(new PropertyDescriptor("onmouseover", //$NON-NLS-1$ add by lovejj
ColumnTag.class,
null,
"setOnmouseover")); //$NON-NLS-1$ add by lovejj
到此就完成了displaytag的标签扩展了.重启服务,修改页面,即可测试
例如:jsp
显示为:
图1:
图2:
图3: