DWR: a nice choice for your ajax implementation

本文介绍了一种使用DWR库简化Ajax开发的方法。通过DWR,开发者无需直接处理XMLHttpRequest或编写Servlet代码,也不需要关心对象序列化及XML转换等工作。DWR能够将服务器端Java对象的方法暴露给JavaScript,使得这些方法可以直接在客户端调用。
This week I got an DWR Ajax example which is used in our JSF JSR 168 Portlet. Actually, before I looked into this sample, I had not expected too much, since for months, I have been keeping looking for an ajax solution for our portlet  project which returns me nothing, either it is too complicated, or it does not work with portlet and JSF lifecycle. Based on all information I collected, I knew for Ajax, you have to deal with XMLHttpRequest,  write your own Servlet code, handle object serialization, turn java object to XML format, and on and on. All these stop us thinking further. For us it is just pain and uncertainty to take Ajax right now although all articles are trying to convince you how easy it is.

However, my mind has been totally changed after this example, I am so excited to know Ajax can be implemented so simple, so clean. The more I know DWR, the more I love this library. With DWR, you do not need to deal with XMLHttpRequest directly, do not need to write Servlet, do not need to take care of serialization, do not need to convert XML, all these laborious jobs will be done by DWR. Besides,  the most beautiful thing of DWR is, it exposes methods of server-side java objects to javascript, which means, the function you have in the java object can be used directly in javascript!

About DWR, there are a lot of useful information on internet, therefore I am not going to expand it here. My intention of writting this is to let you consider DWR for your ajax application if you are seeking for a solution.

Resources

Ajax for Java developers: Ajax with Direct Web Remoting

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值