扩展eXtremeTable 行事件:
修改eXtremeTable 源码增加双击事件:
1. 修改extremecomponents.tld 文件找到Row Tag 增加属性ondblclick
<attribute> <name>ondblclick</name> <required>false</required> <rtexprvalue>true</rtexprvalue>
<description><![CDATA[The javascript ondblclick action -add by lovejj]]></description>
</attribute> |
2. Row.java 文件增加ondblclick属性,并生成相应的get,set方法
private String ondblclick;//add by lovejj |
3. HtmlBuilder.java 增加ondblclick 方法:
/** * @author loveJJ * <p>The ondblclick attribute [ondblclick=].</p> */ public HtmlBuilder ondblclick(String ondblclick) { if (StringUtils.isNotBlank(ondblclick)) { write(" ondblclick=\"").write(ondblclick).write("\" "); }
return this; } |
4. RowBuilder.java 增加ondblclick方法:
public void ondblclick() {//add by lovejj String ondblclick = row.getOndblclick(); html.ondblclick(ondblclick); } |
并修改该类中的 rowStart() 方法为:
public void rowStart() { html.tr(1); styleClass(); style(); onclick(); onmouseover(); onmouseout(); ondblclick();//默认是没有这一行的 add by loveJJ html.close(); } |
5. 修改RowTag.java 文件:
现在就进入到了关键的一步中,在Tag标签类中让其展现出来,首先增加属性
private String ondblclick;//add by lovejj |
然后生成该属性的set方法
public void setOndblclick(String ondblclick) { this.ondblclick = ondblclick; } |
并修改doStartTag()方法:
在else方法中增加一行:
row.setOndblclick(TagUtils.evaluateExpressionAsString("ondblclick", ondblclick, this, pageContext));//add by lovejj |
例如本人修改的doStartTag方法最后为:
public int doStartTag() throws JspException { try { TableModel model = TagUtils.getModel(this);
if (TagUtils.isIteratingBody(this)) { Row row = model.getRowHandler().getRow(); row.setOnclick(TagUtils.evaluateExpressionAsString("onclick", onclick, this, pageContext)); row.setOnmouseout(TagUtils.evaluateExpressionAsString("onmouseout", onmouseout, this, pageContext)); row.setOnmouseover(TagUtils.evaluateExpressionAsString("onmouseover", onmouseover, this, pageContext));
modifyRowAttributes(model, row); model.getRowHandler().modifyRowAttributes(); } else { Row row = new Row(model); row.setHighlightClass(TagUtils.evaluateExpressionAsString("highlightClass", this.highlightClass, this, pageContext)); row.setHighlightRow(TagUtils.evaluateExpressionAsBoolean("highlightRow", this.highlightRow, this, pageContext)); row.setInterceptor(TagUtils.evaluateExpressionAsString("interceptor", this.interceptor, this, pageContext)); row.setOnclick(TagUtils.evaluateExpressionAsString("onclick", onclick, this, pageContext)); row.setOnmouseout(TagUtils.evaluateExpressionAsString("onmouseout", onmouseout, this, pageContext)); row.setOnmouseover(TagUtils.evaluateExpressionAsString("onmouseover", onmouseover, this, pageContext)); row.setStyle(TagUtils.evaluateExpressionAsString("style", style, this, pageContext)); row.setStyleClass(TagUtils.evaluateExpressionAsString("styleClass", styleClass, this, pageContext)); row.setOndblclick(TagUtils.evaluateExpressionAsString("ondblclick", ondblclick, this, pageContext));//add by lovejj
addRowAttributes(model, row); model.addRow(row); } } catch (Exception e) { throw new JspException("RowTag.doStartTag() Problem: " + ExceptionUtils.formatStackTrace(e)); }
return EVAL_BODY_INCLUDE; } |
OK到此修改完毕,
Test.jsp中即可加入
<ec:row ondblclick="alert('sd');"> |
进行测试了.