您的位置:首页 > 其它

关于对DWR继承测试

2006-10-08 15:25 387 查看
超类:
public class Father {
public Father() {
}

public String Myname(){
return "haoxiaojie";
}
} // end
子类:
public class Test_ajax extends Father{

public Test_ajax() {
}

public String myage(){
return "25";
}
} // end

在dwr.xml中的声明:
<create creator="new" javascript="tomajax" scope="request">
<param name="class" value="hxj.tgtc.actions.dwr.Test_ajax"></param>
<include method="Myname"/>
<include method="myage"/>
</create>

执行结果:

Methods For: tomajax (hxj.tgtc.actions.dwr.Test_ajax)

To use this class in your javascript you will need the following script includes:

<script type='text/javascript' src='/tgtc/dwr/interface/tomajax.js'></script>
<script type='text/javascript' src='/tgtc/dwr/engine.js'></script>

In addition there is an optional utility script:

<script type='text/javascript' src='/tgtc/dwr/util.js'></script>

Replies from DWR are shown with a yellow background if they are simple or in an alert box otherwise.
The inputs are evaluated as Javascript so strings must be quoted before execution.

There are 11 declared methods:

myage( );
var reply0 = function(data)
{
if (data != null && typeof data == 'object') alert(DWRUtil.toDescriptiveString(data, 2));
else DWRUtil.setValue('d0', DWRUtil.toDescriptiveString(data, 1));
}
25

Myname( );
var reply1 = function(data)
{
if (data != null && typeof data == 'object') alert(DWRUtil.toDescriptiveString(data, 2));
else DWRUtil.setValue('d1', DWRUtil.toDescriptiveString(data, 1));
}
haoxiaojie

结论:
DWR中的create 元素 是可以使用继承的。以前不知道~~让我费力不少~~弯路~~~初学者需要注意了~~~

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: