根据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了!呵呵
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了!呵呵