dwr direct web remoting

20
DWR - Direct Web Remoting Subramanian Thiruppathi

Upload: tsubramanian80

Post on 14-Jul-2015

980 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: DWR  Direct Web Remoting

DWR - Direct Web Remoting

Subramanian Thiruppathi

Page 2: DWR  Direct Web Remoting

Agenda

Introduction

Step by Step

DWR Demo

Reference

Page 3: DWR  Direct Web Remoting

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

Page 4: DWR  Direct Web Remoting

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

Page 5: DWR  Direct Web Remoting

DWR Developers

Page 6: DWR  Direct Web Remoting

DWR

JavaScript running in the browser that sends requests and can dynamically update the webpage.

Page 7: DWR  Direct Web Remoting

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.

Page 8: DWR  Direct Web Remoting

Step By Step – DWRSample

Page 9: DWR  Direct Web Remoting

Step By Step – Web.xml

Page 10: DWR  Direct Web Remoting

Step By Step – Factorial

Page 11: DWR  Direct Web Remoting

Step By Step – dwr.xml

Page 12: DWR  Direct Web Remoting

Step By Step – Test DWR

Page 13: DWR  Direct Web Remoting

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

Page 14: DWR  Direct Web Remoting

Step By Step – ex1.js

Page 15: DWR  Direct Web Remoting

Step By Step – Done !!!!

Page 16: DWR  Direct Web Remoting

Step By Step – JFactorial.js (Dynamic JS)

Page 17: DWR  Direct Web Remoting

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>

Page 18: DWR  Direct Web Remoting

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.

Page 19: DWR  Direct Web Remoting

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.

Page 20: DWR  Direct Web Remoting

Reference

http://directwebremoting.org/