SlideShare a Scribd company logo
GWT = Easy AJAXConfoo.ca11/3/2010
Who am I?Olivier GérardinTechnical Director, Sfeir Benelux (groupe Sfeir)Java / Web architect13+ years Java3 years GWT
AgendaLittle GWT showcaseWhy GWT?How does it work?Key featuresMyths & misconceptionsPointers, Conclusion, Q&A
GWT ShowcaseSeesmic webGWT Equation editorGWTUMLPiano EtudesClarity AccountingContactOfficeMyERP, CompiereExt-GWT explorerAnd more: Google Wave, Timetonote CRM…
Mandatory and oversimplified history of the dynamic webWhy GWT?
Web 0.0Or “The Link Era”A web page is just a bunch of images and text with linksPages are usually stored (not generated)Links take you to a new pageClick on linkHTTP request is built (from static link URL) and sentWait for server to replyServer replies with HTML page (usually from file)Response received  blank screenWait for entire page to load
Web 1.0Or “The Form Era”In addition to images and text, a web page can contain fields and other widgetsA designated button submits the form Pages are build Fill in formSubmitHTTP request is built (from form parameters and field values) and sentWait for server to replyServer replies with HTML page (usually generated on server)Response received  blank screenWait for entire page to load
Server side processingCGIBasic bridge to OS commandsVery ineffective (1 request = 1 process)Web server / application serverPHP, JSP, ASP, perl, whateverPerformance improvementsOn-demand compilationThread poolingPage is totally reconstructed for every request
1995: here comes JavaScriptClient-side scriptingFirst usage: client-side form validationAvoid server round-trip when invalidInstant feedbackWith DOM: polymorphic client page (DHTML)Menus, animations, etc.Cross-browser (almost)No server interaction without submit/reload 
2000: XHTTPR and AJAXMS introduces Outlook Web AccessWeb “clone” of desktop client (Outlook)Fetches data from server without reloading page!How is that possible?New class: XmlHttpRequestAllows server interaction without page reloadResponse received asynchronouslyInterface updated through DOMAJAX is born!
The first AJAX app: Outlook Web Access
JavaScript frenzyJS becomes hype… Cool-looking, nice to use web UIsEveryone wants to do JavaScriptAny serious web site must have dynamic content, auto-completion or other AJAX goodiesWidget sets / frameworks begin to emergeScriptaculous, YUI, dojo, jScript, …Anything seems possible in JavaScriptJavaScript OS, AjaxSwing (WebCream), …
JavaScript hangoverSerious JavaScript hurts…Cross-browser compatibility nightmareFix in one, break in anotherJavaScript Guru required!Developing/Debugging nightmareWeird runtime errorsNo static typingNo refactoringAnd..Memory leaksHeavy pagesSecurity issues
JavaScript confusionSource: BrowserBook © Visibone
What to do?Option 1: leave the hard work to othersBuild the demo with AJAXWin the contractLeave the team…Option 2: Give up AJAXFor what? Flex? Silverlight? JavaFX?Plugin requiredSEO unfriendlyLearning curveAJAX is too cool!
Google is in the same boatGoogle is a heavy producer of AJAX appsHad to come up with a solution…
GWT solves all your problemsGWT gives you AJAX without the pain of JavaScript developmentTakes care of cross-browser issuesAllows full debugging (breakpoints, step by step, inspecting/watching variables)Strong static typing early error detectionFull refactoring optionsNo browser plugin or mandatory IDEShort learning curveSimple RPC mechanism built inBut can communicate with any server technology
Program in Java…GWT allows developing client-side web apps in full Java (with only a few restrictions)Leverage existing Java tools and skillsUse any IDE (Eclipse, NetBeans, IntelliJ, …)Program like a traditional graphical client (Swing, SWT, …)Widgets, containers, listeners, etc.Use OO patterns (MVC, MVP, observer, composite, etc.)Test like any Java appUse standard Java debuggersTest with JUnit
… deploy in JavaScriptJavaScript is only generated:For deploymentTo test in actual web modeGWT guarantees that the generated JavaScript app behaves exactly like the Java app And it does (most of the time)
How does it work?
4 easy piecesJava-to-JavaScript compilerJRE emulation libraryJava librariesHosted Development mode
GWT compilerGenerates JS code from Java sourcePerforms numerous optimizationsIn most cases better than hand codingCan generate obfuscated (ultra-compact) codeJS plays a role similar to bytecode for compiled Java applicationsShocking!
JRE Emulation libraryProvides a GWT-compatible version of Java core classesMost of java.langMost of java.utilSome classes of java.io and java.sqlFor convenience only! No real I/O or JDBC!Used when running in web modeHosted mode runs in a JVM with standard JRE
GWT Java librariesUtility classesRPC, I18N, …Widget setSimple widgets (Button, TextField, …)Base building blocksIn most cases map to native HTML objectComposites = widgets built from other widgetsPanels = widget containersPanels enforce a layout (vertical, horizontal, grid, …)
GWT widgets: Simple widgets
GWT widgets: Composites
GWT widgets: Panels
Development modeAllows running GWT apps without converting them to JavaScriptCode runs as Java bytecode in a standard JVMDevelopment mode shell emulates JS runtimeActual rendering done by real browserPerforms extensive checks to make sure the code is compilable to JavaScriptBottom line: if a GWT application performs as expected in development mode, it will perform identically in web mode99,9% of the time…
Luxembourg interesting factsCultural break
Luxembourg is very smallFits inside a 82 x 67 km rectanglePopulation < 500k (Montréal: 1.6 m)
Luxembourg City is beautiful
Luxembourg has a lot of castles
Luxembourg TriviaWorld’s only Grand-DuchyMore than 150k cross-border workers50% of the capital city’s population during working hours3 official languages (fr, de, lu)Highest GDP per capitaImportant financial center (funds)Home of Europe’s largest TV/radio company (RTL group)2 hours away from Paris by TGV / international airport
Back to GWT:Key features
Easy developmentDuring development, you are writing and running a classic Java appUse your favorite IDEAll IDE features available (code completion, code analysis, refactoring, links, Javadoc, …)Plugins help GWT-specific taskslaunching development modecompilingrefactoringcreating projects, modules, RPC services, …even design GUI (GWT Designer from Instantiations)
Easy RPC implementationRPC mechanism based on Java servletsEasy as:Define service interfaceintadd (intx, inty);Derive asynchronous interfacevoid add (intx, inty, AsyncCallback<Integer> callback);Implement service interface	publicint add (intx, inty) {		returnx + y;	}
Easy RPC consumptionEasy as:Obtain service proxyAddServiceAsyncaddService = GWT.create(AddService.class);Call methodaddService.add(x, y, newAsyncCallback<Long>() {	publicvoidonFailure(Throwable caught) {		// handle failure	}	publicvoidonSuccess(Integer result) {		// handle success	}});
Easy RPC deploymentRPC services are actually POJS (plain old Java servlets)Can be deployed without changes in any servlet engineIntegrated test server uses standard web.xml format for declaring services
Easy JSON generationEasy as:JSONObjectlivre = newJSONObject();livre.put("Titre", newJSONString("GWT"));livre.put("Pages", new JSONNumber(123));JSONArraychapitres = newJSONArray();chapitres.set(0, newJSONString("Introduction"));
Easy JSON parsingEasy as:JSONObjectlivre = newJSONObject(json);String titre = livre.get("Titre").isString().stringValue();doublepages = livre.get("Pages").isNumber().doubleValue();JSONArraychapitres = livre.isArray();String chap0 = chapitres.get(0).isString().stringValue();
Deferred bindingAppropriate code for user environment (browser, locale) is chosen at application startup time≠ dynamic binding (implementation chosen at runtime)≠ static binding (implementation chosen at compile time)Code for every combination is generated at compile timeAdvantages:Allows app-wide optimizationsCompensates for the lack of dynamic (runtime) loadingDisadvantages:Increases compilation time
Deferred Binding (explicit)Deferred binding can be called explicitly:Foofoo = GWT.create(Foo.class);Implementation is provided by either:Substitution: an existing class is designatedGeneration: class is generated during compilation
Easy native JavaScript integrationImplement a method directly in JavaScript:publicstaticnativevoidalert(Stringmsg) /*-{	$wnd.alert(msg);}-*/;Call back Java methods from JavaScriptPass objects back and forthUseful to Wrap legacy JavaScript librariesAccess browser functionality not exposed by GWTDangerous! Easily breaks cross-browser compatibility
Easy Widget reuseCreate your own widgets:Extend existing widgetWorks but not the most efficientMight expose unwanted methods from superclassExtend CompositeRecommended methodUse JSNITo wrap existing JavaScript widgets
Easy history supportAJAX app = single page“back” button  catastrophe…GWT solution:Encode app state in URL as “fragment”E.g. http://myserver/myGwtApp#x=1;y=2Save state:History.newItem(token);React to state change (“back” button)History.addValueChangeHandler(…);
I18n: constant substitutionDefine interfacepublicinterfaceAppConstantsextends Constants {  String title();}“Implement” interfaceAppConstants.properties: 		title = Hello, WorldAppConstants_fr_CA.properties: 	title = Salut, Monde	…UseAppConstantsappConstants = GWT.create(AppConstants.class);String title = appConstants.title();
I18n: template substitutionDefine interfacepublicinterfaceAppMessagesextends Messages {  String mailStatus(intn, String s);}“Implement” interface (AppMessages.properties)mailStatus = You have {0} messages in folder {1}Use:AppMessagesmsgs = GWT.create(AppMessages.class);String status = msgs.mailStatus(15, “Inbox”);
Easy debuggingIn development mode, application runs as bytecode (just like any old Java app…)So you can debug it just like any classic Java app:Set breakpointsStep through codeInspect variablesChange variables…
Short dev cycleChange client code:press “Reload”.. Done!Change server code:Embedded server: press “Restart”.. Done!External server: hotswap /redeploy if needed
Easy client-server testingIntegrated application server for testing RPC servicesCan be disabled to use external serverJUnit integration to run client-side test cases Hosted mode or web modeFull access to RPC servicesGWTTestCase, GWTTestSuite for automationSelenium for automated GUI testing
Easy scalingAll session data resides on clientSimilar to classic fat clientNo session information on server-sideForget session affinityAdd/remove servers on the flyRestart server without losing clients
“Easy” stylingStyling relies entirely on CSSWidgets have well-known style namesProgrammer can add custom stylesNo shift from traditional HTML stylingHTML/DOM build page “skeleton”Appearance tuned with CSSSeparate UI construction from stylingWith well thought styles, it’s possible to reskin completely an application without changing one line of codeGWT styling has all the benefits of CSS with all problems of CSSBe careful with brower dependencies!
Easy Google AJAX APIsProject gwt-google-apishttp://code.google.com/p/gwt-google-apisLibraries that wrap Google JavaScript APIsMapsGears (storage, obsoleted by HTML5)Gadgets (embedable applets)AJAX search (embedded google search)Visualization (charts)Language (translation, language detection)Standalone libraries (do not require JavaScript libraries)
[new in 2.0] in-browser development modeBefore 2.0: hosted mode uses customized browser engineHeavily customizedOnly one supported browser per platform (IE on Windows, WebKit on Mac, Mozilla on Linux)Difficult to keep up-to-dateIncludes platform-specific code (SWT)Browser and hosted application share the same processMost plugins don’t work (including Google Gears…)
[new in 2.0] in-browser development modenow:Hosted mode shell runs outside browserCommunicates with browser using plugin through TCP
[new in 2.0] in-browser development modeBenefitsUse any (supported) browser/version on any platformBehavior closer to web modeNo interference with browser pluginsNo more platform-specific stuff in GWT (one jar for all!)Network protocol cross-platform possibleDev mode shell on machine X, slave browser on machine YE.g. dev on Linux, test in IE on Windows…
[new in 2.0] speed tracerPerformance analysis toolVisualize where your app spends time:JS executionBrowser renderingCSS handling (style selection/calculation)DOM handling (event processing)Resource loading
[new in 2.0] code splittingBefore: monolithic download can become very bigSlow startup timesAfter: Programmer can insert “split points” in codeHints for the compiler to place everything not required up to split point in separate downloadCompiler divides code in several “chunks”, which are loaded on-demandBenefits:Initial loading time reduced 50% on average with a single split pointAllows on-demand module loading (provider pattern)
[new in 2.0] declarative UIDeclarative construction of GUI using XML grammarAllows automatic binding with Java code (through annotations)Automatically assign references to dynamically created widgets to designated Java fields (@UiField)Automatically attach methods as event handlers (@UiHandler)Benefits:Clearly separate:Static UI construction (XML)Dynamic UI behavior (Java)
[new in 2.0] resource bundleDownload multiple heterogeneous resources from server in a single requestImages (already possible in pre-2.0)CSSTextAny binary resourceBenefits:Fewer round trips to the serverLess overheadMore responsive interface
[new in 2.0] and also…Compiler optimizationsMostly generated JS sizeDraft compile modeFaster buildsNot for deployment!Layout panelsPredictable, consistent layoutConstraint based system built on top of CSSPlays nice with custom CSS stylesHtmlUnitNo native code / browser required
Myths & misconceptions
Myth: GWT is a JS library/framework/widget setGWT is not for JavaScript developersProvides only Java classes
Myth: GWT is a frameworkGWT is a toolkit (set of tools)Frameworks may be built on top of it
Myth: GWT is appletsA GWT application is 100% JavaScriptNo runtime/pluginNo JRE required
Myth: GWT is only for Java programmersYes, GWT uses Java as programming language…BUT you can also see it this way:GWT lets you write/debug/test/refactor AJAX apps with state-of-the-art IDEs and tools using a statically-typed object-oriented languageGWT makes it worth learning Java!
Myth: GWT generates poorly performing JSThe GWT compiler generates highly optimized and compact codeHand written JavaScript might be marginally faster in some cases, but it’s not worth the trouble
Myth: GWT only works with a Java backendGWT includes a simple and efficient RPC mechanism that relies on Java servletsBUT it plays nice with any server-side technology that can handle HTTP requests (even PHP)Includes XML encoding/decoding libraryIncludes JSON encoding/decoding library
Myth: GWT has poor UI componentsYes, GWT’sbuiltin widgets are minimalistic…BUT GWT’s point is not to provide a complete and beautiful widget setGWT provides the basis for rich and good-looking componentsCreate your own or use 3rd partySee Ext-GWT, SmartGWT
Myth: GWT apps have long startup timesNot longer than any JavaScript appObfuscation reduces sizeDeferred binding loads just the necessary code for the platform/languageGWT 2.0’s code splitting can split code in several chunksSmaller initial downloadOn-demand downloading
Myth: GWT doesn’t integrate with existing sitesGWT was designed from the beginning with the goal to integrate well into existing sitesGWT can build the UI from a blank HTML page or alter existing elementsVery easy to add GWT to an existing pageOnly a few lines of HTML to load the moduleCan “hook up” to any DOM element (through its ID)
Myth: GWT has poor skinning possibilitiesGWT uses CSS for stylingCan reskin a whole application without changing a line of code (done that!)Can split work between developer (behavior) and designer (appearance)Caution: CSS can introduce browser dependencies
ConclusionIs GWT the future of web development?GWT has passed reality checkGive it a try!GWT = easy AJAX now !=
PointersGWT home (downloads, docs, FAQs, guides, etc.)http://code.google.com/toolkitGoogle groups “GWT” grouphttp://groups.google.com/group/Google-Web-ToolkitonGWT: fresh news about GWThttp://www.ongwt.comLinkedIn “GWT Users” grouphttp://www.linkedin.com/groups?gid=129889
Shameless self-promotion
Thank youQuestions?gerardin.o@sfeir.lublog.gerardin.info@ogerardin

More Related Content

PDF
How to make Ajax work for you
KEY
Mobile HTML, CSS, and JavaScript
PPT
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
KEY
the 5 layers of web accessibility - Open Web Camp II
PDF
High Performance JavaScript - WebDirections USA 2010
PDF
Js Saturday 2013 your jQuery could perform better
PPT
Ajax Performance
PPT
JsUnit
How to make Ajax work for you
Mobile HTML, CSS, and JavaScript
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
the 5 layers of web accessibility - Open Web Camp II
High Performance JavaScript - WebDirections USA 2010
Js Saturday 2013 your jQuery could perform better
Ajax Performance
JsUnit

What's hot (20)

PDF
Ajax Security
PPT
High Performance Ajax Applications
PDF
JavaScript and BOM events
PDF
JavaScript Library Overview
PDF
Performance, Games, and Distributed Testing in JavaScript
PPTX
User Interface Patterns and Nuxeo
PDF
HTML5 and the dawn of rich mobile web applications pt 1
PDF
The DOM is a Mess @ Yahoo
PDF
Web versus Native: round 1!
PDF
Introduction to jQuery
PDF
High Performance JavaScript - Fronteers 2010
PDF
Angular or Backbone: Go Mobile!
PPT
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
PDF
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
PDF
Building Web Sites that Work Everywhere
PDF
Empowering the "mobile web"
PDF
jQuery Proven Performance Tips & Tricks
PDF
Bootstrap과 UI-Bootstrap
PDF
Developing High Performance Web Apps
PPTX
JavaScript Presentation Frameworks and Libraries
Ajax Security
High Performance Ajax Applications
JavaScript and BOM events
JavaScript Library Overview
Performance, Games, and Distributed Testing in JavaScript
User Interface Patterns and Nuxeo
HTML5 and the dawn of rich mobile web applications pt 1
The DOM is a Mess @ Yahoo
Web versus Native: round 1!
Introduction to jQuery
High Performance JavaScript - Fronteers 2010
Angular or Backbone: Go Mobile!
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Building Web Sites that Work Everywhere
Empowering the "mobile web"
jQuery Proven Performance Tips & Tricks
Bootstrap과 UI-Bootstrap
Developing High Performance Web Apps
JavaScript Presentation Frameworks and Libraries
Ad

Viewers also liked (20)

PDF
All about GWT
PPT
GWT Training - Session 2/3
PDF
GWT Overview And Feature Preview - SV Web JUG - June 16 2009
PDF
Secrets of the GWT
PDF
Architecting your GWT applications with GWT-Platform - Lesson 02
PPT
GWT Extreme!
PPT
GWT Training - Session 3/3
PPT
GWT Training - Session 1/3
PDF
Comparing Flex, Grails, GWT, Seam, Struts 2 and Wicket
PDF
Web Frameworks of the Future: Flex, GWT, Grails and Rails
PPT
Zend_Acl
PPTX
BluemixでGWTアプリケーションを動かす
PDF
Introduction maven3 and gwt2.5 rc2 - Lesson 01
PPT
Hibernate
PPT
instalar postgresql php
PPT
Ireport
PPT
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
PPT
GWT + Gears : The browser is the platform
PDF
GWT Brand Guidelines 1.1
PDF
Develop Gwt application in TDD
All about GWT
GWT Training - Session 2/3
GWT Overview And Feature Preview - SV Web JUG - June 16 2009
Secrets of the GWT
Architecting your GWT applications with GWT-Platform - Lesson 02
GWT Extreme!
GWT Training - Session 3/3
GWT Training - Session 1/3
Comparing Flex, Grails, GWT, Seam, Struts 2 and Wicket
Web Frameworks of the Future: Flex, GWT, Grails and Rails
Zend_Acl
BluemixでGWTアプリケーションを動かす
Introduction maven3 and gwt2.5 rc2 - Lesson 01
Hibernate
instalar postgresql php
Ireport
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
GWT + Gears : The browser is the platform
GWT Brand Guidelines 1.1
Develop Gwt application in TDD
Ad

Similar to GWT = easy AJAX (20)

PPT
PPT
Google Web Toolkit Introduction - eXo Platform SEA
PPT
Gwt Presentation1
PPTX
Gwt session
PPT
Introduction to Google Web Toolkit
PDF
GWT - Building Rich Internet Applications Using OO Tools
PPTX
Gwt session
PPTX
Gwt overview & getting started
PPT
GWT is Smarter Than You
PPT
Google Web Toolkits
PPTX
Google web toolkit ( Gwt )
PDF
Javascript as a target language - GWT KickOff - Part 2/2
PPT
Google Dev Day2007
ODP
Google Web toolkit
ODP
Building Ajax apps with the Google Web Toolkit
PPTX
YaJUG: What's new in GWT2
PDF
GWT - AppDays - (25 aprile 2014, pordenone)
PDF
GWT training session 1
PDF
T 0230 Google Wave Powered By Gwt
Google Web Toolkit Introduction - eXo Platform SEA
Gwt Presentation1
Gwt session
Introduction to Google Web Toolkit
GWT - Building Rich Internet Applications Using OO Tools
Gwt session
Gwt overview & getting started
GWT is Smarter Than You
Google Web Toolkits
Google web toolkit ( Gwt )
Javascript as a target language - GWT KickOff - Part 2/2
Google Dev Day2007
Google Web toolkit
Building Ajax apps with the Google Web Toolkit
YaJUG: What's new in GWT2
GWT - AppDays - (25 aprile 2014, pordenone)
GWT training session 1
T 0230 Google Wave Powered By Gwt

Recently uploaded (20)

PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Electronic commerce courselecture one. Pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Approach and Philosophy of On baking technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
NewMind AI Weekly Chronicles - August'25 Week I
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Cloud computing and distributed systems.
PDF
Modernizing your data center with Dell and AMD
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Machine learning based COVID-19 study performance prediction
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Empathic Computing: Creating Shared Understanding
Per capita expenditure prediction using model stacking based on satellite ima...
Electronic commerce courselecture one. Pdf
Encapsulation_ Review paper, used for researhc scholars
Approach and Philosophy of On baking technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
NewMind AI Monthly Chronicles - July 2025
NewMind AI Weekly Chronicles - August'25 Week I
The AUB Centre for AI in Media Proposal.docx
Unlocking AI with Model Context Protocol (MCP)
Understanding_Digital_Forensics_Presentation.pptx
Cloud computing and distributed systems.
Modernizing your data center with Dell and AMD
Building Integrated photovoltaic BIPV_UPV.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...

GWT = easy AJAX

  • 1. GWT = Easy AJAXConfoo.ca11/3/2010
  • 2. Who am I?Olivier GérardinTechnical Director, Sfeir Benelux (groupe Sfeir)Java / Web architect13+ years Java3 years GWT
  • 3. AgendaLittle GWT showcaseWhy GWT?How does it work?Key featuresMyths & misconceptionsPointers, Conclusion, Q&A
  • 4. GWT ShowcaseSeesmic webGWT Equation editorGWTUMLPiano EtudesClarity AccountingContactOfficeMyERP, CompiereExt-GWT explorerAnd more: Google Wave, Timetonote CRM…
  • 5. Mandatory and oversimplified history of the dynamic webWhy GWT?
  • 6. Web 0.0Or “The Link Era”A web page is just a bunch of images and text with linksPages are usually stored (not generated)Links take you to a new pageClick on linkHTTP request is built (from static link URL) and sentWait for server to replyServer replies with HTML page (usually from file)Response received  blank screenWait for entire page to load
  • 7. Web 1.0Or “The Form Era”In addition to images and text, a web page can contain fields and other widgetsA designated button submits the form Pages are build Fill in formSubmitHTTP request is built (from form parameters and field values) and sentWait for server to replyServer replies with HTML page (usually generated on server)Response received  blank screenWait for entire page to load
  • 8. Server side processingCGIBasic bridge to OS commandsVery ineffective (1 request = 1 process)Web server / application serverPHP, JSP, ASP, perl, whateverPerformance improvementsOn-demand compilationThread poolingPage is totally reconstructed for every request
  • 9. 1995: here comes JavaScriptClient-side scriptingFirst usage: client-side form validationAvoid server round-trip when invalidInstant feedbackWith DOM: polymorphic client page (DHTML)Menus, animations, etc.Cross-browser (almost)No server interaction without submit/reload 
  • 10. 2000: XHTTPR and AJAXMS introduces Outlook Web AccessWeb “clone” of desktop client (Outlook)Fetches data from server without reloading page!How is that possible?New class: XmlHttpRequestAllows server interaction without page reloadResponse received asynchronouslyInterface updated through DOMAJAX is born!
  • 11. The first AJAX app: Outlook Web Access
  • 12. JavaScript frenzyJS becomes hype… Cool-looking, nice to use web UIsEveryone wants to do JavaScriptAny serious web site must have dynamic content, auto-completion or other AJAX goodiesWidget sets / frameworks begin to emergeScriptaculous, YUI, dojo, jScript, …Anything seems possible in JavaScriptJavaScript OS, AjaxSwing (WebCream), …
  • 13. JavaScript hangoverSerious JavaScript hurts…Cross-browser compatibility nightmareFix in one, break in anotherJavaScript Guru required!Developing/Debugging nightmareWeird runtime errorsNo static typingNo refactoringAnd..Memory leaksHeavy pagesSecurity issues
  • 15. What to do?Option 1: leave the hard work to othersBuild the demo with AJAXWin the contractLeave the team…Option 2: Give up AJAXFor what? Flex? Silverlight? JavaFX?Plugin requiredSEO unfriendlyLearning curveAJAX is too cool!
  • 16. Google is in the same boatGoogle is a heavy producer of AJAX appsHad to come up with a solution…
  • 17. GWT solves all your problemsGWT gives you AJAX without the pain of JavaScript developmentTakes care of cross-browser issuesAllows full debugging (breakpoints, step by step, inspecting/watching variables)Strong static typing early error detectionFull refactoring optionsNo browser plugin or mandatory IDEShort learning curveSimple RPC mechanism built inBut can communicate with any server technology
  • 18. Program in Java…GWT allows developing client-side web apps in full Java (with only a few restrictions)Leverage existing Java tools and skillsUse any IDE (Eclipse, NetBeans, IntelliJ, …)Program like a traditional graphical client (Swing, SWT, …)Widgets, containers, listeners, etc.Use OO patterns (MVC, MVP, observer, composite, etc.)Test like any Java appUse standard Java debuggersTest with JUnit
  • 19. … deploy in JavaScriptJavaScript is only generated:For deploymentTo test in actual web modeGWT guarantees that the generated JavaScript app behaves exactly like the Java app And it does (most of the time)
  • 20. How does it work?
  • 21. 4 easy piecesJava-to-JavaScript compilerJRE emulation libraryJava librariesHosted Development mode
  • 22. GWT compilerGenerates JS code from Java sourcePerforms numerous optimizationsIn most cases better than hand codingCan generate obfuscated (ultra-compact) codeJS plays a role similar to bytecode for compiled Java applicationsShocking!
  • 23. JRE Emulation libraryProvides a GWT-compatible version of Java core classesMost of java.langMost of java.utilSome classes of java.io and java.sqlFor convenience only! No real I/O or JDBC!Used when running in web modeHosted mode runs in a JVM with standard JRE
  • 24. GWT Java librariesUtility classesRPC, I18N, …Widget setSimple widgets (Button, TextField, …)Base building blocksIn most cases map to native HTML objectComposites = widgets built from other widgetsPanels = widget containersPanels enforce a layout (vertical, horizontal, grid, …)
  • 28. Development modeAllows running GWT apps without converting them to JavaScriptCode runs as Java bytecode in a standard JVMDevelopment mode shell emulates JS runtimeActual rendering done by real browserPerforms extensive checks to make sure the code is compilable to JavaScriptBottom line: if a GWT application performs as expected in development mode, it will perform identically in web mode99,9% of the time…
  • 30. Luxembourg is very smallFits inside a 82 x 67 km rectanglePopulation < 500k (Montréal: 1.6 m)
  • 31. Luxembourg City is beautiful
  • 32. Luxembourg has a lot of castles
  • 33. Luxembourg TriviaWorld’s only Grand-DuchyMore than 150k cross-border workers50% of the capital city’s population during working hours3 official languages (fr, de, lu)Highest GDP per capitaImportant financial center (funds)Home of Europe’s largest TV/radio company (RTL group)2 hours away from Paris by TGV / international airport
  • 34. Back to GWT:Key features
  • 35. Easy developmentDuring development, you are writing and running a classic Java appUse your favorite IDEAll IDE features available (code completion, code analysis, refactoring, links, Javadoc, …)Plugins help GWT-specific taskslaunching development modecompilingrefactoringcreating projects, modules, RPC services, …even design GUI (GWT Designer from Instantiations)
  • 36. Easy RPC implementationRPC mechanism based on Java servletsEasy as:Define service interfaceintadd (intx, inty);Derive asynchronous interfacevoid add (intx, inty, AsyncCallback<Integer> callback);Implement service interface publicint add (intx, inty) { returnx + y; }
  • 37. Easy RPC consumptionEasy as:Obtain service proxyAddServiceAsyncaddService = GWT.create(AddService.class);Call methodaddService.add(x, y, newAsyncCallback<Long>() { publicvoidonFailure(Throwable caught) { // handle failure } publicvoidonSuccess(Integer result) { // handle success }});
  • 38. Easy RPC deploymentRPC services are actually POJS (plain old Java servlets)Can be deployed without changes in any servlet engineIntegrated test server uses standard web.xml format for declaring services
  • 39. Easy JSON generationEasy as:JSONObjectlivre = newJSONObject();livre.put("Titre", newJSONString("GWT"));livre.put("Pages", new JSONNumber(123));JSONArraychapitres = newJSONArray();chapitres.set(0, newJSONString("Introduction"));
  • 40. Easy JSON parsingEasy as:JSONObjectlivre = newJSONObject(json);String titre = livre.get("Titre").isString().stringValue();doublepages = livre.get("Pages").isNumber().doubleValue();JSONArraychapitres = livre.isArray();String chap0 = chapitres.get(0).isString().stringValue();
  • 41. Deferred bindingAppropriate code for user environment (browser, locale) is chosen at application startup time≠ dynamic binding (implementation chosen at runtime)≠ static binding (implementation chosen at compile time)Code for every combination is generated at compile timeAdvantages:Allows app-wide optimizationsCompensates for the lack of dynamic (runtime) loadingDisadvantages:Increases compilation time
  • 42. Deferred Binding (explicit)Deferred binding can be called explicitly:Foofoo = GWT.create(Foo.class);Implementation is provided by either:Substitution: an existing class is designatedGeneration: class is generated during compilation
  • 43. Easy native JavaScript integrationImplement a method directly in JavaScript:publicstaticnativevoidalert(Stringmsg) /*-{ $wnd.alert(msg);}-*/;Call back Java methods from JavaScriptPass objects back and forthUseful to Wrap legacy JavaScript librariesAccess browser functionality not exposed by GWTDangerous! Easily breaks cross-browser compatibility
  • 44. Easy Widget reuseCreate your own widgets:Extend existing widgetWorks but not the most efficientMight expose unwanted methods from superclassExtend CompositeRecommended methodUse JSNITo wrap existing JavaScript widgets
  • 45. Easy history supportAJAX app = single page“back” button  catastrophe…GWT solution:Encode app state in URL as “fragment”E.g. http://myserver/myGwtApp#x=1;y=2Save state:History.newItem(token);React to state change (“back” button)History.addValueChangeHandler(…);
  • 46. I18n: constant substitutionDefine interfacepublicinterfaceAppConstantsextends Constants { String title();}“Implement” interfaceAppConstants.properties: title = Hello, WorldAppConstants_fr_CA.properties: title = Salut, Monde …UseAppConstantsappConstants = GWT.create(AppConstants.class);String title = appConstants.title();
  • 47. I18n: template substitutionDefine interfacepublicinterfaceAppMessagesextends Messages { String mailStatus(intn, String s);}“Implement” interface (AppMessages.properties)mailStatus = You have {0} messages in folder {1}Use:AppMessagesmsgs = GWT.create(AppMessages.class);String status = msgs.mailStatus(15, “Inbox”);
  • 48. Easy debuggingIn development mode, application runs as bytecode (just like any old Java app…)So you can debug it just like any classic Java app:Set breakpointsStep through codeInspect variablesChange variables…
  • 49. Short dev cycleChange client code:press “Reload”.. Done!Change server code:Embedded server: press “Restart”.. Done!External server: hotswap /redeploy if needed
  • 50. Easy client-server testingIntegrated application server for testing RPC servicesCan be disabled to use external serverJUnit integration to run client-side test cases Hosted mode or web modeFull access to RPC servicesGWTTestCase, GWTTestSuite for automationSelenium for automated GUI testing
  • 51. Easy scalingAll session data resides on clientSimilar to classic fat clientNo session information on server-sideForget session affinityAdd/remove servers on the flyRestart server without losing clients
  • 52. “Easy” stylingStyling relies entirely on CSSWidgets have well-known style namesProgrammer can add custom stylesNo shift from traditional HTML stylingHTML/DOM build page “skeleton”Appearance tuned with CSSSeparate UI construction from stylingWith well thought styles, it’s possible to reskin completely an application without changing one line of codeGWT styling has all the benefits of CSS with all problems of CSSBe careful with brower dependencies!
  • 53. Easy Google AJAX APIsProject gwt-google-apishttp://code.google.com/p/gwt-google-apisLibraries that wrap Google JavaScript APIsMapsGears (storage, obsoleted by HTML5)Gadgets (embedable applets)AJAX search (embedded google search)Visualization (charts)Language (translation, language detection)Standalone libraries (do not require JavaScript libraries)
  • 54. [new in 2.0] in-browser development modeBefore 2.0: hosted mode uses customized browser engineHeavily customizedOnly one supported browser per platform (IE on Windows, WebKit on Mac, Mozilla on Linux)Difficult to keep up-to-dateIncludes platform-specific code (SWT)Browser and hosted application share the same processMost plugins don’t work (including Google Gears…)
  • 55. [new in 2.0] in-browser development modenow:Hosted mode shell runs outside browserCommunicates with browser using plugin through TCP
  • 56. [new in 2.0] in-browser development modeBenefitsUse any (supported) browser/version on any platformBehavior closer to web modeNo interference with browser pluginsNo more platform-specific stuff in GWT (one jar for all!)Network protocol cross-platform possibleDev mode shell on machine X, slave browser on machine YE.g. dev on Linux, test in IE on Windows…
  • 57. [new in 2.0] speed tracerPerformance analysis toolVisualize where your app spends time:JS executionBrowser renderingCSS handling (style selection/calculation)DOM handling (event processing)Resource loading
  • 58. [new in 2.0] code splittingBefore: monolithic download can become very bigSlow startup timesAfter: Programmer can insert “split points” in codeHints for the compiler to place everything not required up to split point in separate downloadCompiler divides code in several “chunks”, which are loaded on-demandBenefits:Initial loading time reduced 50% on average with a single split pointAllows on-demand module loading (provider pattern)
  • 59. [new in 2.0] declarative UIDeclarative construction of GUI using XML grammarAllows automatic binding with Java code (through annotations)Automatically assign references to dynamically created widgets to designated Java fields (@UiField)Automatically attach methods as event handlers (@UiHandler)Benefits:Clearly separate:Static UI construction (XML)Dynamic UI behavior (Java)
  • 60. [new in 2.0] resource bundleDownload multiple heterogeneous resources from server in a single requestImages (already possible in pre-2.0)CSSTextAny binary resourceBenefits:Fewer round trips to the serverLess overheadMore responsive interface
  • 61. [new in 2.0] and also…Compiler optimizationsMostly generated JS sizeDraft compile modeFaster buildsNot for deployment!Layout panelsPredictable, consistent layoutConstraint based system built on top of CSSPlays nice with custom CSS stylesHtmlUnitNo native code / browser required
  • 63. Myth: GWT is a JS library/framework/widget setGWT is not for JavaScript developersProvides only Java classes
  • 64. Myth: GWT is a frameworkGWT is a toolkit (set of tools)Frameworks may be built on top of it
  • 65. Myth: GWT is appletsA GWT application is 100% JavaScriptNo runtime/pluginNo JRE required
  • 66. Myth: GWT is only for Java programmersYes, GWT uses Java as programming language…BUT you can also see it this way:GWT lets you write/debug/test/refactor AJAX apps with state-of-the-art IDEs and tools using a statically-typed object-oriented languageGWT makes it worth learning Java!
  • 67. Myth: GWT generates poorly performing JSThe GWT compiler generates highly optimized and compact codeHand written JavaScript might be marginally faster in some cases, but it’s not worth the trouble
  • 68. Myth: GWT only works with a Java backendGWT includes a simple and efficient RPC mechanism that relies on Java servletsBUT it plays nice with any server-side technology that can handle HTTP requests (even PHP)Includes XML encoding/decoding libraryIncludes JSON encoding/decoding library
  • 69. Myth: GWT has poor UI componentsYes, GWT’sbuiltin widgets are minimalistic…BUT GWT’s point is not to provide a complete and beautiful widget setGWT provides the basis for rich and good-looking componentsCreate your own or use 3rd partySee Ext-GWT, SmartGWT
  • 70. Myth: GWT apps have long startup timesNot longer than any JavaScript appObfuscation reduces sizeDeferred binding loads just the necessary code for the platform/languageGWT 2.0’s code splitting can split code in several chunksSmaller initial downloadOn-demand downloading
  • 71. Myth: GWT doesn’t integrate with existing sitesGWT was designed from the beginning with the goal to integrate well into existing sitesGWT can build the UI from a blank HTML page or alter existing elementsVery easy to add GWT to an existing pageOnly a few lines of HTML to load the moduleCan “hook up” to any DOM element (through its ID)
  • 72. Myth: GWT has poor skinning possibilitiesGWT uses CSS for stylingCan reskin a whole application without changing a line of code (done that!)Can split work between developer (behavior) and designer (appearance)Caution: CSS can introduce browser dependencies
  • 73. ConclusionIs GWT the future of web development?GWT has passed reality checkGive it a try!GWT = easy AJAX now !=
  • 74. PointersGWT home (downloads, docs, FAQs, guides, etc.)http://code.google.com/toolkitGoogle groups “GWT” grouphttp://groups.google.com/group/Google-Web-ToolkitonGWT: fresh news about GWThttp://www.ongwt.comLinkedIn “GWT Users” grouphttp://www.linkedin.com/groups?gid=129889

Editor's Notes

  • #5: MyERP: Mime_Inc, admin/9p5fJJ_AHCompiere: Server:    http://open.compiere.comUser ID:    Olivier GérardinPassword:    20004098
  • #7: A améliorer (dessin/anim)Exemple: http://web.archive.org/web/19961223105317/http://www.feedmag.com/
  • #8: A améliorer (dessin/anim)
  • #9: Étayer les arguments
  • #10: Origine du nom JavaScript: accord entre Netscape et Sun pour promouvoir la marque “Java”
  • #15: BrowserBpook: http://www.visibone.com/products/browserbook.html
  • #23: Side discussion: high-level languages vs low-level languages. Make the point that although using GWT means giving up some JS idioms, the benefits are elsewhere.
  • #25: Native HTML widgets use the system’s native look &amp; feel.
  • #29: Native Javascript (JSNI) works in dev mode too
  • #37: No constraints on server-side code (plain Java bytecode)
  • #42: GWT performs “Browser sniffing” (controversy)
  • #44: Works
  • #49: DEMO if time allows
  • #50: DEMO if time allows
  • #53: Improved with GWT 2.0
  • #54: Gears phased out fro HTML5