Introduction to Google Web Toolkit

61
Google Web Toolkit Introduction Didier Girard – [email protected] 2008

description

 

Transcript of Introduction to Google Web Toolkit

Page 1: Introduction to Google Web Toolkit

Google Web ToolkitIntroductionDidier Girard – [email protected]

Page 2: Introduction to Google Web Toolkit

Content

• Demonstrations

• Why GWT ?

• How does it run ?

• GWT features

Page 3: Introduction to Google Web Toolkit

DEMONSTRATION

Page 4: Introduction to Google Web Toolkit

Démonstrations

Page 5: Introduction to Google Web Toolkit

Demonstrations

• http://stuff.ongwt.com

Page 6: Introduction to Google Web Toolkit

GWT,FOR C*O LEVEL…

Page 7: Introduction to Google Web Toolkit

GWT is MDI compatible*

• GWT applications could have windows residing under a single parent window.

*MDI : Multiple Document Interface

Page 8: Introduction to Google Web Toolkit

GWT is simple

• Developing a web application with GWT is as simple as developing a Windows application with VB

Page 9: Introduction to Google Web Toolkit

GWT cuts costs

• Building a GWT application is 5 times faster than building a J2EE application

Page 10: Introduction to Google Web Toolkit

GWT is offline compatible

• A GWT application doesn’t need a server

Page 11: Introduction to Google Web Toolkit

GWT, better ergonomic

http://swissmiss.typepad.com/weblog/2007/11/task-clips.html

Web 1.0

GWT

Page 12: Introduction to Google Web Toolkit

GWT applications are efficient

• Local computation, bandwidth optimization

Page 13: Introduction to Google Web Toolkit
Page 14: Introduction to Google Web Toolkit

14

Ajax advantages

Page 15: Introduction to Google Web Toolkit

Ajax : Partial update of the screen

• No more « Blank page » effect

Page 16: Introduction to Google Web Toolkit

Ajax : Asynchronous updates

• Fresh data without reload

Page 17: Introduction to Google Web Toolkit

Ajax : Rich Widgets

• Widgets : One more beautiful than the other

Page 18: Introduction to Google Web Toolkit

Ajax : Better scalability

• Stateless Server

• Statefull client

ApplicationApplication

GUI+BusinessGUI+Business

+ Session+ Session

Data BaseData BaseDataData

Page 19: Introduction to Google Web Toolkit

At first, Ajax is really cool

• So beautiful

• So efficient

• Customers love it

Page 20: Introduction to Google Web Toolkit

But, what about…

• … cross-browser

• … memory leak

• … loading latency

• … « Javascript PhD »

• … ajax IDE

• … bugs (javascript is a dynamic language)

• … cross browser javascript debugger

• … security

• …

Page 21: Introduction to Google Web Toolkit

The solution – First step

• Build the prototype of the application

– It is really fun

– Everybody will admire you

Page 22: Introduction to Google Web Toolkit

The solution – Second step

• Your customer purchases : leave the project :-)

Page 23: Introduction to Google Web Toolkit

Or…

Page 24: Introduction to Google Web Toolkit

Choose

GWT

Page 25: Introduction to Google Web Toolkit

GWT, HOW DOES IT RUN ?

Page 26: Introduction to Google Web Toolkit

GWT manifest

• GWT should help to code stable, efficient and cross-browser applications

• GWT should be friendly for developers

– Compatible with IDE, support debugging, refactoring, strong typing…

• The based line : « First the user, second the developer » - Bruce Johnson

Page 27: Introduction to Google Web Toolkit

The approach

• Code in java

• Compile the java to Javascript

Page 28: Introduction to Google Web Toolkit

Hello World

• Demonstration

Page 29: Introduction to Google Web Toolkit

BrowserIE, Firefox, Safari, Opera

BrowserIE, Firefox, Safari, Opera

RWA in JavaRWA in Java

Java Runtime LibraryJava Runtime Library

Architecture

java.langjava.lang

java.utiljava.util

Java.ioJava.io

Application code

GWT GUI LibraryGWT GUI Library

Panels

PopupStack

AbsoluteVertical

WidgetsButton MenuBar

Radio TreeCheck Table

TextArea ….

Javascript Application

GWT Runtime100Ko

GWTCompiler

GWTCompiler

Page 30: Introduction to Google Web Toolkit

OVERVIEWS

Page 31: Introduction to Google Web Toolkit

Widgets : « 100% java »

• Demonstration (Kitchen Sink)

http://code.google.com/webtoolkit/examples/kitchensink/

Page 32: Introduction to Google Web Toolkit

History support

• « Single Page Interface » with history support !

• Demonstration (Kitchen Sink)

• Code :

History.addHistoryListener(myCommand);

Page 33: Introduction to Google Web Toolkit

RPC Support (JSON/XML-RPC)

• AJAX is a story of asynchronous request

– With GWT, it is simple !

Page 34: Introduction to Google Web Toolkit

I18N/L10N support

• Simple and powerfull

Page 35: Introduction to Google Web Toolkit

Absolute Panel

• Rapid Application Development : sometime, you need it

– Absolute panel : a pleasure !

• A panel of Panels : Grid, Row, Flex, Vertical, Tab,…

Page 36: Introduction to Google Web Toolkit

Cross browser, cross platform

Page 37: Introduction to Google Web Toolkit

CSS

• GWT widgets are CSS compatible

Page 38: Introduction to Google Web Toolkit

Debugger

• Demonstration

Page 39: Introduction to Google Web Toolkit

Javascript integration

• JSNI, a clever API

• Many javascript library are already wrapped : Dojo, Extjs,…

• Demonstration

public static native void alert(String msg) /*-{ $wnd.alert(msg); }-*/;

Page 40: Introduction to Google Web Toolkit

Optimization

• Compiled javascript is optimized

• Only the necessary javascript is downloaded by the browser

– IE downloads only javascript for IE, Firefox downloads only javascript for Firefox

– Unused APIs are removed from the compiled javascript

Page 41: Introduction to Google Web Toolkit

Good scalability

• GWT server could be stateless

• No more session affinity

Page 42: Introduction to Google Web Toolkit

Tools

• GWT is supported by all the java IDE : Eclipse, NetBeans, IntelliJ IDEA, JDeveloper,…

• Advertisement : my favorite tool is GWT Designer

Page 43: Introduction to Google Web Toolkit

GWT : THE Community

• Millions of download

• 11000 subscribers to the forum

• Books

• Tones of Books

• Tones of tutorials

• Blogs

Page 44: Introduction to Google Web Toolkit

GWT 1.4, faster, faster, faster

• Example : ImageBundle, kind of database for images

– From 12 requests to 1 request…

ClippedImage timeIcon = new ClippedImage("icons.png", 22, 0, 22, 22);

http://roberthanson.blogspot.com/2007/02/gwt-clippedimage-optimizing-image.html

Page 45: Introduction to Google Web Toolkit

GWT Gears

• Gears helps to build offline application

• GWT wrapper :

– http://code.google.com/p/gwt-google-apis/

• Demo

45 Google Confidential

Page 46: Introduction to Google Web Toolkit

GWT : summary

• It is 5 times faster to build a GWT application

– Refactoring

– Debugging

– Stateless server

– Cross-browsers

– I18N

– Hosted mode

– JSNI

Page 47: Introduction to Google Web Toolkit

TIPS AND TRICKS

Page 48: Introduction to Google Web Toolkit

Think differently!

• Rethink application ergonomic.

• Forget browsing

• MDI is possible

• Stateless server, statefull client

• -> Demo

• http://code.google.com/p/gdf

48 Google Confidential

Page 49: Introduction to Google Web Toolkit

A language is behind the other

• It is not a java application, it is javascript application coded with the java API !

• For example, « long » is not a javascript type !

• -> Demonstration

49 Google Confidential

Page 50: Introduction to Google Web Toolkit

Misc

• DOM manipulation is costly

– Your user can have : « slow script message » 

– -> Use « IncrementalCommand » (DEMO)

• No need to send tones of asynchronous request

• Deal with RPC error by subclassing AsyncCallback

• Forget javascript

• Use Selenium (DEMO)

• Use Maven

50 Google Confidential

Page 51: Introduction to Google Web Toolkit

COMMONPLACE

Page 52: Introduction to Google Web Toolkit

You must used java on the server

• No, GWT is server free

Page 53: Introduction to Google Web Toolkit

Compiled javascript is impossible to debug

• It is possible to change compilation option

• But you never need to it,

• -> Demo

Page 54: Introduction to Google Web Toolkit

GWT Widgets ? Bof….

• GWT widgets are basic

• It is really easy to build its own widget

• Many libraries

– GWT Ext

– GWT Rialto

– Tatami

– GWT Widget

– GWTaculous

– MyGWT

– …

54 Google Confidential

Page 55: Introduction to Google Web Toolkit

GWT are heavy

• Compiled javascript is light and gzippable

– KitchenSink is around 60Ko !

Page 56: Introduction to Google Web Toolkit

GWT is HTML incompatible

• Wrong

– It is possible to include GWT components in a classical HTML page

Page 57: Introduction to Google Web Toolkit

GWT are applets

• Applets, no thanks :-)

– Java is compiled to javascript !

Page 58: Introduction to Google Web Toolkit

GWT is not free

• Noooo

– GWT is opensource (Apache licence)

Page 59: Introduction to Google Web Toolkit

Ressources

GWT :http://code.google.com/webtoolkit/

Forum :http://groups.google.com/group/Google-Web-Toolkit

GWT Blog : http://googlewebtoolkit.blogspot.com/

onGWT, Tracking news on GWT : http://www.ongwt.com/

Page 60: Introduction to Google Web Toolkit

SFEIR

• 6 projects with GWT

– 5000 days of coding

– It is just fun

– Clients are very happy with their applications

– Our stack : GWT/Spring/Hibernate

• Jobs: [email protected]

60 Google Confidential

Page 61: Introduction to Google Web Toolkit

ConclusionGWT, c’est facile, efficace et beau !Merci à l’équipe GWT, Merci à la communauté, Merci à Google !