dwr direct web remoting
TRANSCRIPT
DWR - Direct Web Remoting
Subramanian Thiruppathi
Agenda
Introduction
Step by Step
DWR Demo
Reference
DWR
DWR is a Java library that enables Java on the server and JavaScript in a browser to interact and call each other as simply as possible.
DWR is Easy Ajax for Java DWR is Open Source, available under the Apache
Software License v2 DWR provides integration with Dojo and Spring etc., Version
– Latest Version: 3.0.rc1– Current stable release: 2.0
Who is using DWR
Bank of America Citigroup Deutschebank Permanent General Dow Jones RSA Security Cap Gemini The International Olympic Committee, IBM in the US, China and India Caterpillar 20th Century Fox UCG Lufthansa
DWR Developers
DWR
JavaScript running in the browser that sends requests and can dynamically update the webpage.
Reverse Ajax (available since DWR version 2.0)
A Java Servlet running on the server that processes requests and sends responses back to the browser.
Step By Step – DWRSample
Step By Step – Web.xml
Step By Step – Factorial
Step By Step – dwr.xml
Step By Step – Test DWR
Step By Step – ex1.html
engine.js: Handles all server communication util.js: Helps you alter web pages with the
data you got from the server
Step By Step – ex1.js
Step By Step – Done !!!!
Step By Step – JFactorial.js (Dynamic JS)
More info - DWR
More than one remote calls use batch
dwr.engine.beginBatch();Remote.method1(params, callback1);Remote.method2(params, callback2);dwr.engine.endBatch();
Dwr.xml
<allow> <create creator="..." javascript="..." scope="...">
<param name="..." value="..."/> <auth method="..." role="..."/> <exclude method="..."/> <include method="..."/>
</create></allow>
More info - DWR
Dwr.xml<allow>
<create creator="..." javascript="..." scope="..."> <param name="..." value="..."/> <exclude method="..."/> <include method="..."/>
</create></allow>
The creator attributes specifies how DWR creates a Java object. It can be : New - This uses the java obejcts new operator. This is very commonly used None – it does not create any object. This assumes that the object has already been created
by someone else or the method to be called static Scripted – It uses a scripting language to create objects like BSF (Bean Scripting Framework)
or BeanShell Spring – It uses Spring framework to give accesses to a Java Object Jsf – it enables JSF managed beans to be remoted Struts – It enables Struts FormBeans as remoted objects. Pageflow – it gives accesses to weblogic / Beehive PageFlow Objects.
More info - DWR
Dwr.xml<allow>
<create creator="..." javascript="..." scope="..."> <param name="..." value="..."/> <exclude method="..."/> <include method="..."/>
</create></allow>
The javascript attributes gives the Java object name that is used in the browser side. The scope element is used to specify where a bean is available. It can be
– Application– Request– Session– Page– Script The first four are the same as in servlet development and script allows a bean to be tied to an ID in a
page rather than an HTTP session cookie.The default scope is page Two elements include and exclude are used to limit access to class methods.
Reference
http://directwebremoting.org/