DWR: a nice choice for your ajax implementation

来源:互联网 发布:js防止注入攻击代码 编辑:程序博客网 时间:2024/04/29 21:55
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

原创粉丝点击