dwr2.0实现java改变html的控件属性值

根据dwr官方文档,2.0M2具有了如题的这个属性,但是提供的范例中我们找不到所说的DWRUtil。细细查看,终于在http://getahead.org/dwr/changelog/dwr20上找到了答案,看这行dwr.util (the new name for DWRUtil),原来改名了。但是这个页面上的范例和目前官方公布的最新版本的包还是有出入的。(我用的版本version: 2.0.rc2
scc-info: $Id: dwr-version.properties,v 1.52 2007/01/04 13:09:20 joe_walker Exp $)

成功的实现如下:
Table.java


import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;
import org.directwebremoting.proxy.dwr.*;

public class Table {

public Table() {
super();
// TODO Auto-generated constructor stub
}

public void newRow(){
WebContext wctx = WebContextFactory.get();

Util utilThis = new Util(wctx.getScriptSession());
utilThis.setStyle("bu","visibility","hidden");
utilThis.setValue("txtUser","testUser2");

}
}


htm端

<html>
<head>
<Meta http-equiv="Content-Type" Content="text/html; Charset=gb2312">
</head>
<script type='text/javascript' src='/dwr/interface/Table.js'></script>
<script type='text/javascript' src='/dwr/engine.js'></script>
<script type='text/javascript' src='/dwr/util.js'></script>
<script>
function con(){
Table.newRow();
}
</script>
<body>
<input type="text" name="txtUser">
<input type="button" name="bu" value="button" οnclick="con();">
</body>
</html>

这样就OK了!呵呵
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值