Dwr is a framework for Ajax developers. It is easy to use.
Refer the site for more
<blockquote>http://directwebremoting.org/</blockquote>
Dwr Xml
---------
<blockquote><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 0.4//EN" "http://www.getahead.ltd.uk/dwr/dwr.dtd">
<dwr>
<allow>
<create creator="new" javascript="ViewDataJS">
<param name="class" value="com.hylafax.view.ViewData"/>
</create>
<convert converter="bean"
match="com.hylafax.sent.SentDetail"/>
</allow>
</dwr></blockquote>
in dwr xml, create tag creates a new js object of a java class. here "ViewData" java class has been converted to a "ViewDataJS" js script.
convert tag is used to convert object types to js. here "SentDetail" java class objects are converted.
In your jsps
---------------
<blockquote><script type='text/javascript'
src='/Project/dwr/interface/ViewData.js'></script>
<script type='text/javascript'
src='/Project/dwr/engine.js'></script></blockquote>
you have to add dwr jar file to your project. after that you can call your js methods which are in your java class.
you can access your script urls by typing :
http://localhost:8080/Test/dwr
here Test is your project
calling methods in java class
------------------------------
you can call methods like this
ViewDataJS.getReceiveList(division,gotBReceivedFax);
here "division" is the prameter for the getReceiveList method. you can get the results with gotBReceivedFax method.
No comments:
Post a Comment