There are 2 ways to get started with DWR, the easy way is to download the WAR file and have a look around, however this does not help you see how easily DWR integrates with your current web application, so the following 3 simple steps are recommended:
Download the dwr.jar file. Place it in the
WEB-INF/lib directory of your webapp. You'll probably have a set of jar files in there already.
The following lines need to be added to
<servlet> section needs to go with the other
<servlet> sections, and likewise with the
<servlet> <servlet-name>dwr-invoker</servlet-name> <display-name>DWR Servlet</display-name> <servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>true</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>dwr-invoker</servlet-name> <url-pattern>/dwr/*</url-pattern> </servlet-mapping>
Then create a dwr.xml file that lives in WEB-INF alongside web.xml. A simple way to start is with something like this:
new creator that we used above uses the public no-args constructor that all JavaBeans must have. It is also worth remembering that DWR has a few restrictions:
You should see a page showing you the classes that you've selected in step 2. Having followed a link you should see an index of all the methods all ready for calling. These pages are dynamically generated examples of what you can do using DWR.
Kick the tyres and have a look around.
There are a number of examples in the sidebar that demonstrate how to dynamically alter the text in web pages, update lists, manipulate forms and do live table editing. Each has a description of how it works.
Another way to get started is to look at the source from the pages that you just viewed:
<script src='/[YOUR-WEBAPP]/dwr/interface/[YOUR-SCRIPT].js'></script> <script src='/[YOUR-WEBAPP]/dwr/engine.js'></script>
You can omit the
/[YOUR-WEBAPP]/ section and use relative paths in your web pages if you wish.
We have a log of common problems and their fixes. This is the first place to look.
If you are still having problems please join the mailing list and ask there.
Ajax开发框架+用户名检测实例(调试通过) - Jul 03, 2006
Ajax按需读取数据生成下级菜单[转] - Jul 03, 2006
Ajax在PHP开发中的应用[转] - Jun 27, 2006
利用PHP和AJAX创建RSS聚合器 - May 10, 2006
Ajax文档 - May 01, 2006