DWR: 创建与JAVA对象对应的JS对象。
2009-02-17 10:57
567 查看
使用DWR,可以非常方便的将一个JS对象转变成一个JAVA对象,提供数据给后台进行处理。
下面是的官方网站例子:
And
Then you can call this from Javascript like this:
Any fields missing from the Javascript representation will be left unset in the Java version.
Since the setter returned 'void' we did not need to use a callback and could just leave it out. If you want to be notified of the completion of a server-side method that returns void then you can include a callback method. Obviously DWR will not pass any data to it.
下面是的官方网站例子:
Creating Javascript objects to match Java objects
Suppose you have an exposed Java method like this:public class Remote { public void setPerson(Person p) { this.person = p; } }
And
Personlooks like this:
public Person { private String name; private int age; private Date[] appointments; // getters and setters ... }
Then you can call this from Javascript like this:
var p = { name:"Fred Bloggs", age:42, appointments:[ new Date(), new Date("1 Jan 2008") ] }; Remote.setPerson(p);
Any fields missing from the Javascript representation will be left unset in the Java version.
Since the setter returned 'void' we did not need to use a callback and could just leave it out. If you want to be notified of the completion of a server-side method that returns void then you can include a callback method. Obviously DWR will not pass any data to it.
相关文章推荐
- js+ajax处理java后台返回的json对象循环创建到表格的方法
- js对象的创建 js对象和java对象的不同
- java 对象创建的5种方式
- 从头认识java-4.1 创建与初始化对象
- java中创建对象的5种方式
- java创建对象的四种方式
- js创建对象的4中方式(初学者可以看看)
- 创建js对象
- Java中常见的创建对象几种方式
- java笔记 对象的创建和对象调用方法的详细过程
- 深入理解js面向对象——创建对象
- Java中什么是匿名对象,空参构造方法输出创建了几个匿名对象,属性声明成static
- js创建对象的方法汇总
- js 创建对象的三种方式——工厂模式、构造函数模式、原型模式
- JS 创建对象(常见的几种方法)
- js 创建对象的几种方式
- java对象的创建和销毁
- java创建对象五种方法
- Cocos2d-Js中创建对象都使用new 对象,而且每个对象前面都要加cc.例如