Gwt - relief from ajax pain

59
1 GWT Relief from ajax pain

description

GWT - Relief from AJAX pain

Transcript of Gwt - relief from ajax pain

Page 1: Gwt - relief from ajax pain

1

GWTRelief from ajax pain

Page 2: Gwt - relief from ajax pain

About me

2

Prayag Upd Sr JVM Platform Programmer Zazzercode Inc

Page 3: Gwt - relief from ajax pain

Agenda

3

1. invention of ajax /ˈeɪdʒæks/2. pain in ajax3. GWT to the rescue4. GWT dev tools5. GWT app architecture6. Who is using GWT7. QA

Page 4: Gwt - relief from ajax pain

1. invention of ajax

4

2004 - Gmail first most interactive web based email client to use XMLHttpRequest

Page 5: Gwt - relief from ajax pain

1. invention of ajax

5

XMLHttpRequest a JavaScript object easy way to retrieve data from a URL without having to do a full page refresh.

XMLHttpRequest URL

Page 6: Gwt - relief from ajax pain

1. invention of ajax

6

XMLHttpRequest

var xhr = new XMLHttpRequest();xhr.open('GET', 'http://api.twitter.com/', false); xhr.onreadystatechange = function (aEvt) { if (xhr.readyState == 4) { if(xhr.status == 200) dump(xhr.responseText); else dump("Error loading page\n"); }};xhr.send(null);

Page 7: Gwt - relief from ajax pain

1. invention of ajax

7

2004 - Rediffmail announced the use of XMLHttpRequest.

Page 8: Gwt - relief from ajax pain

1. invention of ajax

8

Google Suggest

May 2005 - Google Personlize(iGoogle) drag and drop aspect of JavaScript and a seamless integration with the async behavior of XMLHttpRequest.

Page 9: Gwt - relief from ajax pain

1. invention of ajax

9

Google’s orkut feature like star rating

2005 - Google mapallowing users to locate and view places on any point across the world all in the same browser

Page 10: Gwt - relief from ajax pain

1. invention of ajax

10

Google’s stand with XMLHttpRequest has truly laid out the foundation for how AJAX is being used today.

Page 11: Gwt - relief from ajax pain

1. invention of ajax

11

2005, Jesse James Garrett coined a term AJAX

Page 12: Gwt - relief from ajax pain

1. invention of ajax

12

HTML/CSSPresentation

AJAX incorporates

Page 13: Gwt - relief from ajax pain

1. invention of ajax

13

HTML/CSSPresentation

DOMdynamic display

AJAX incorporates

Page 14: Gwt - relief from ajax pain

1. invention of ajax

14

HTML/CSSPresentation

DOMdynamic display

XML/JSON

AJAX incorporates

Page 15: Gwt - relief from ajax pain

1. invention of ajax

15

HTML/CSSPresentation

DOMdynamic display

XML/JSON

XMLHttpRequest

AJAX incorporates

Page 16: Gwt - relief from ajax pain

1. invention of ajax

16

DOMdynamic display

XML/JSON

XMLHttpRequest

Server

AJAX incorporates

HTML/CSSPresentation

JS

Page 17: Gwt - relief from ajax pain

1. invention of ajax

17

Page 18: Gwt - relief from ajax pain

1. invention of ajax

18

Page 19: Gwt - relief from ajax pain

2. Pain in AJAX

19

Programming time

Page 20: Gwt - relief from ajax pain

2. Pain in AJAX

20

Programming time

JS cross-browser quirks

HTML CSSXML

Page 21: Gwt - relief from ajax pain

2. Pain in AJAX

21

Programming time

JS cross-browser quirks

HTML CSSXML

के मा स नु

?

Page 22: Gwt - relief from ajax pain

2. Pain in AJAX

22

debugging is not easier

Page 23: Gwt - relief from ajax pain

2. Pain in AJAX

23

debugging is not easier अ घ मा च लरा कोड का ो लेम ्आयो फेर ?

Page 24: Gwt - relief from ajax pain

2. Pain in AJAX

24

RPC Overhead

a connection needs to be established and HTTP headers (cookies etc.) are passed with every request.

Page 25: Gwt - relief from ajax pain

3. GWT to the rescue

25

Page 26: Gwt - relief from ajax pain

3. GWT to the rescue

26

GWT

/ˈɡwɪt/

Page 27: Gwt - relief from ajax pain

3. GWT to the rescue

27

program and debug AJAX-based apps in Java

common Java dev tools

using

Page 28: Gwt - relief from ajax pain

3. GWT to the rescue

28

deploy the same apps as client-side HTML and JS, and server-side Java.

tomcat

deploy

Page 29: Gwt - relief from ajax pain

3. GWT to the rescue

29

provides JRE emulation library (a subset of the java.lang and java.util packages)

Page 30: Gwt - relief from ajax pain

3. GWT to the rescue

30

Java2JavaScript compiler

Page 31: Gwt - relief from ajax pain

3. GWT to the rescue

31

Java2JavaScript compiler

zazzercode.js

Zazzercode.java

AddUserView.java

AddUserPresenter.java

User.java

GWT compiler

Page 32: Gwt - relief from ajax pain

3. GWT to the rescue

32

Hosted Web browser

Page 33: Gwt - relief from ajax pain

3. GWT to the rescue

33

Hosted Web browser

JVM

Zazzercode.java

AddUserView.java

AddUserPresenter.java

User.java

runs as Java bytecode

Page 34: Gwt - relief from ajax pain

3. GWT to the rescue

34

Web UI class library

Page 35: Gwt - relief from ajax pain

3. GWT to the rescue

35

Web UI class library

Page 36: Gwt - relief from ajax pain

3. GWT to the rescue

36

Web UI class library - DatePicker exampleimport com.google.gwt.user.datepicker.client.DatePicker;

DatePicker datePicker = new DatePicker();

Page 37: Gwt - relief from ajax pain

3. GWT to the rescue

37

Web UI class library - DatePicker exampleimport com.google.gwt.user.datepicker.client.DatePicker;

DatePicker datePicker = new DatePicker();// Set the default valuedatePicker.setValue(new Date(), true);

VerticalPanel panel = new VerticalPanel();panel.add(datePicker);

RootPanel.get("gwtContainer").add(panel);

Page 38: Gwt - relief from ajax pain

3. GWT to the rescue

38

GWT simplifies typical AJAX-style RPC conversations between client-side(JavaScript) and server-side (Java).

Page 39: Gwt - relief from ajax pain

3. GWT to the rescue

39

Page 41: Gwt - relief from ajax pain

5. GWT app architecture

41

Page 42: Gwt - relief from ajax pain

5. GWT app architecture

42

server layer

shared layer

client layer

Page 43: Gwt - relief from ajax pain

5. GWT app architecture

43

server layer -Spring,JDBC, Hibernate

shared layer-common shared objects

client layer -GWT views

Page 44: Gwt - relief from ajax pain

5. GWT app architecture

44

GWT

RPC server layer -Spring,JDBC, Hibernate

shared layer-common shared objects

client layer -GWT views

Page 45: Gwt - relief from ajax pain

5. GWT app architecture

45

Page 46: Gwt - relief from ajax pain

5. GWT app architecture

46

Screencast available at gwt rpc using eclipse plugin, http://www.youtube.com/watch?v=-rDe0PiUkaI

Page 47: Gwt - relief from ajax pain

6. Who is using GWT

47

google adwords

Page 48: Gwt - relief from ajax pain

6. Who is using GWT

48

orkut

Page 49: Gwt - relief from ajax pain

6. Who is using GWT

49

evernote

Page 50: Gwt - relief from ajax pain

6. Who is using GWT

50

chrome.angrybirds.com/

Page 51: Gwt - relief from ajax pain

7. QA

51

?

Page 52: Gwt - relief from ajax pain

Thank You

Page 56: Gwt - relief from ajax pain

References

[7] Be aware of AJAX's drawbacks, http://www.techrepublic.com/blog/software-engineer/be-aware-of-ajaxs-drawbacks/

[8] What is the disadvantage of using websocket/socket.io where ajax will do?, http://stackoverflow.com/a/6829575/432903

Page 57: Gwt - relief from ajax pain

References

[9] What is the disadvantage of DWR?, http://stackoverflow.com/a/1006625/432903

[10] Is GWT's RPC different from AJAX?, http://stackoverflow.com/a/13736656/432903

Page 59: Gwt - relief from ajax pain

References

[13] Using XMLHttpRequest, https://developer.mozilla.org/es/docs/XMLHttpRequest/Usar_XMLHttpRequest

[14] Is GWT's RPC different from AJAX?, http://stackoverflow.com/a/13736656/432903