SlideShare a Scribd company logo
Google Web Toolkit (GWT) by Do Hoang Khiem (Collaboration Team)
Agenda What is & Why GWT? Building User Interface GWT Widgets Event handling Apply styles Remote Procedure Call (RPC) GWT RPC Serializable type Handling Exception
Agenda History management Internationalization JUnit Testing Javascript Native Interface (JSNI)
What's and Why GWT?
What is GWT? Java software development framework that makes writing AJAX applications easy Google announced GWT at the JavaOne 2006 Latest version: 2.2.0 February 11, 2011 Let you   develop and debug AJAX applications in the Java language   using Java development tools Eclipse, Netbeans, IntelliJ, … Provides   Java-to-Javascript   compiler and development mode that helps you debug your GWT applications
GWT SDK & Tools GWT SDK: contains Java API libraries, compiler, development  server and tools Plugin for Eclipse: provides IDE support for GWT and App Engine web projects Some other tools: GWT Designer Speed Tracker Maven plugins
Two modes of running GWT App Development mode (hosted mode) GWT application is run as Java bytecode within JVM Take advantage of Java debugging Production mode (web mode) Your GWT application is run as pure Javascript and HTML compiled from original Java source code End user will only see the web mode version of your application
Why GWT? Static type checking in Java language boots productivity while reducing errors Easily caught common Javascript errors typos, type mismatches, ... Take advantage of Java refactoring, code completion, ... Java-based Object-Oriented designs are easier to communicate and understand.
Why GWT? No need to write “excellent” Javascript code Leverage your Java programming knowledge No need to take care of browser incompatibilities and quirks GWT compiler handles them Support browser history, backward, forward Use Java API to manipulate DOM Take advantage from rich built-in Widgets
Why GWT? Leverage various tools of Java programming for writing, debugging, testing Ex: Eclipse, IntelliJ, Netbeans JUnit integration Internationalization
GWT Architecture Overview
GWT Architecture Overview GWT Java-to-Javascript compiler Translates Java source code to Javascript code GWT Hosted Web Browser Let you run and debug your GWT application in development mode, where  your code run as Java bytecode within JVM JRE emulation library A small subset of JRE to handle the Java to Javascript conversion. This of the JRE emulation library as representing the Javascript capabilities GWT Web UI class library A set of custom interfaces and classes for creating widgets.
Building User Interface
GWT User Interface GWT user interface classes are similar to those in existing UI frameworks such as Swing  and SWT. GWT widgets are rendered using dynamically-created HTML rather than pixel-oriented graphics While GWT provides access to the browser's DOM directly using the DOM package, it is far easier to use classes from the Widget hierarchy The Widget classes make it easier to quickly build interfaces that will work correctly on all browsers.
Widgets Library Widgets Library Images
Widgets Library
Widgets Library Widgets Library Images
Event Handler Events in GWT use the handler model similar to other user interface frameworks A handler interface defines one or more methods that the widget calls to announce an event A class wishing to receive events of a particular type implements the associated handler interface and then passes a reference to itself to the widget to subscribe to a set of events.
Event Handler Example public void anonClickHandlerExample() { Button b = new Button("Click Me"); b.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // handle the click event } }); }
Apply styles GWT applications use CSS for visual styling  Update styles dynamically in Java code Associate style sheets with the project Using a <link> tag in the host HTML page. Using the <stylesheet> element in the module XML file.
Remote Procedure Call (RPC)
GWT Remote Procedure Call Mechanism for interacting with server by invoking a method Ex: fetching data from server GWT RPC makes it easy for the client and server to pass Java objects back and forth over HTTP GWT provides serialization mechanism to bridge between client and server Any object that needs to send is a GWT Serialization type Proper use of GWT RPC can allow you to develop an application where all the UI logic resides on the client, leaving  business logic on the server) Resulting in an application with greatly improved performance, reduced bandwidth, and reduced web server load
GWT RPC plumbing architecture
Implementing GWT RPC Define an interface for your service that extends RemoteService and lists all RPC method called “Synchronous Interface” Implement the service at server-side This class extends RemoteServiceServlet and implement the created interface Define an asynchronous interface to your service to be called from the client-side code Based on original service interface Require caller to pass callback object that can be notified when async call completes.
Serializable Types GWT RPC method parameters and return types must be serializable These values will be transmitted across network between client and server Java data types are already serializable Primitive, such as char, byte, short, int, long, boolean, float, or double. String, Date or primitive wrapper: Character, Integer, Byte, Double, … Array of serializable types Serializable user-defined class The type has at least one serializable subclass
Handling Exception Making RPCs opens up the possibility of a variety of errors Networks fail, servers crash, and problems occur while processing a server call. GWT lets you handle these conditions in terms of Java exceptions Caller should implement  AsyncCallBack.onFailure(Throwable)  to handle exception
History management
GWT History Mechanism GWT applications use “history token” to help Ajax developer activate browser history The token will be saved in browser history as a URL fragment Ex: http://www.example.com/historyexample/HistoryExample.html#page1 To enable history to your Ajax Add a history token to the history stack when you want to enable history event Create an object that implements the ValueChangeHandler interface, parses new token and changes the application state to match
GWT History GWT history demo
Internationalization
Internationalization GWT offers multiple internationalization techniques Static String Internationalization Dynamic String Internationalization Static String Internationalization Extends Constants Interface Extends Message Interface Use properties files Dynamic String Internationalization
Internationalization Demo
JUnit Testing
JUnit Testing GWT provides integration with the popular JUnit  unit testing framework  GWT allows JUnit test cases to run in either development mode or production mode.
JUnit Testing Demo.
Javascript Native Interface (JSNI)
Why JSNI? Sometimes it's very useful to mix handwritten Javascript to Java source code Ex: access low-level browser functionality not exposed by the GWT API You can use JSNI to: Implement a Java method directly in JavaScript Wrap type-safe Java method signatures around existing JavaScript Call from JavaScript code into Java code and vice-versa Throw exceptions across Java/JavaScript boundaries Read and write Java fields from JavaScript Use development mode to debug both Java source (with a Java debugger) and JavaScript (with a script debugger)
JSNI Demo
Resources http://code.google.com/webtoolkit/ Main site for GWT http://googlewebtoolkit.blogspot.com/ http://developerlife.com
Question & Answer

More Related Content

What's hot (20)

PDF
Five android architecture
Tomislav Homan
 
PDF
Building modular monoliths that could scale to microservices (only if they ne...
David Gómez García
 
PPTX
Eco system apps
Sergey Seletsky
 
PPTX
Lecture android best practices
eleksdev
 
PPT
JAVA SCRIPT
Go4Guru
 
PDF
Modern Web Cloud Architecture based on Google Technologies
Michael Ludwig
 
PPTX
Web Performance & Latest in React
Talentica Software
 
PDF
Dropwizard Spring - the perfect Java REST server stack
Jacek Furmankiewicz
 
PPTX
Step by step guide to create theme for liferay dxp 7
Azilen Technologies Pvt. Ltd.
 
PPTX
Qt quick at Cybercom Developer Day 2010 by Alexis Menard 7.9.2010
CybercomChannel
 
PPTX
Microservices - Event-driven & the hidden landmines
Vijay Redkar
 
PDF
Guice tutorial
Anh Quân
 
PPTX
Introduction to Google Guice
Knoldus Inc.
 
PPTX
The Past Year in Spring for Apache Geode
VMware Tanzu
 
PPTX
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
Javier García Magna
 
PPTX
Building Microservices with .NET (speaker Anton Vasilenko, Binary Studio)
Binary Studio
 
PDF
T 0230 Google Wave Powered By Gwt
supertoy2015
 
PDF
A Closer Look At React Native
Ian Wang
 
PDF
I/O Extended (GDG Bogor) - Andrew Kurniadi
Dicoding
 
PPTX
Reactjs Introduction - Virtual DOM
Tamir Azrab
 
Five android architecture
Tomislav Homan
 
Building modular monoliths that could scale to microservices (only if they ne...
David Gómez García
 
Eco system apps
Sergey Seletsky
 
Lecture android best practices
eleksdev
 
JAVA SCRIPT
Go4Guru
 
Modern Web Cloud Architecture based on Google Technologies
Michael Ludwig
 
Web Performance & Latest in React
Talentica Software
 
Dropwizard Spring - the perfect Java REST server stack
Jacek Furmankiewicz
 
Step by step guide to create theme for liferay dxp 7
Azilen Technologies Pvt. Ltd.
 
Qt quick at Cybercom Developer Day 2010 by Alexis Menard 7.9.2010
CybercomChannel
 
Microservices - Event-driven & the hidden landmines
Vijay Redkar
 
Guice tutorial
Anh Quân
 
Introduction to Google Guice
Knoldus Inc.
 
The Past Year in Spring for Apache Geode
VMware Tanzu
 
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
Javier García Magna
 
Building Microservices with .NET (speaker Anton Vasilenko, Binary Studio)
Binary Studio
 
T 0230 Google Wave Powered By Gwt
supertoy2015
 
A Closer Look At React Native
Ian Wang
 
I/O Extended (GDG Bogor) - Andrew Kurniadi
Dicoding
 
Reactjs Introduction - Virtual DOM
Tamir Azrab
 

Similar to Google Web Toolkit Introduction - eXo Platform SEA (20)

PPTX
Gwt session
Mans Jug
 
PPTX
GWT = easy AJAX
Olivier Gérardin
 
PPT
GWT
Lorraine JUG
 
PDF
GWT - Building Rich Internet Applications Using OO Tools
barciszewski
 
PPTX
Google web toolkit ( Gwt )
Pankaj Bhasker
 
PPT
GWT Training - Session 1/3
Faiz Bashir
 
PPTX
Gwt overview & getting started
Binh Bui
 
PPT
Gwt Presentation1
rajakumar.tu
 
PDF
Introduction to Google Web Toolkit - part 1
Muhammad Ghazali
 
PDF
Javascript as a target language - GWT KickOff - Part 2/2
JooinK
 
PDF
GWT - AppDays - (25 aprile 2014, pordenone)
firenze-gtug
 
ODP
Google Web toolkit
Priyank Kapadia
 
ODP
Building Ajax apps with the Google Web Toolkit
vivek_prahlad
 
PDF
Gwt kickoff - Alberto Mancini & Francesca Tosi
firenze-gtug
 
PDF
Google Web Toolkit
Software Park Thailand
 
PDF
GWT training session 1
SNEHAL MASNE
 
PDF
GWT-Basics
tutorialsruby
 
PDF
GWT-Basics
tutorialsruby
 
PPT
Introduction to Google Web Toolkit
Didier Girard
 
PDF
Introduction to Google Web Toolkit
Jeppe Rishede
 
Gwt session
Mans Jug
 
GWT = easy AJAX
Olivier Gérardin
 
GWT - Building Rich Internet Applications Using OO Tools
barciszewski
 
Google web toolkit ( Gwt )
Pankaj Bhasker
 
GWT Training - Session 1/3
Faiz Bashir
 
Gwt overview & getting started
Binh Bui
 
Gwt Presentation1
rajakumar.tu
 
Introduction to Google Web Toolkit - part 1
Muhammad Ghazali
 
Javascript as a target language - GWT KickOff - Part 2/2
JooinK
 
GWT - AppDays - (25 aprile 2014, pordenone)
firenze-gtug
 
Google Web toolkit
Priyank Kapadia
 
Building Ajax apps with the Google Web Toolkit
vivek_prahlad
 
Gwt kickoff - Alberto Mancini & Francesca Tosi
firenze-gtug
 
Google Web Toolkit
Software Park Thailand
 
GWT training session 1
SNEHAL MASNE
 
GWT-Basics
tutorialsruby
 
GWT-Basics
tutorialsruby
 
Introduction to Google Web Toolkit
Didier Girard
 
Introduction to Google Web Toolkit
Jeppe Rishede
 
Ad

Recently uploaded (20)

PDF
Learn Computer Forensics, Second Edition
AnuraShantha7
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Learn Computer Forensics, Second Edition
AnuraShantha7
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Ad

Google Web Toolkit Introduction - eXo Platform SEA

  • 1. Google Web Toolkit (GWT) by Do Hoang Khiem (Collaboration Team)
  • 2. Agenda What is & Why GWT? Building User Interface GWT Widgets Event handling Apply styles Remote Procedure Call (RPC) GWT RPC Serializable type Handling Exception
  • 3. Agenda History management Internationalization JUnit Testing Javascript Native Interface (JSNI)
  • 5. What is GWT? Java software development framework that makes writing AJAX applications easy Google announced GWT at the JavaOne 2006 Latest version: 2.2.0 February 11, 2011 Let you develop and debug AJAX applications in the Java language using Java development tools Eclipse, Netbeans, IntelliJ, … Provides Java-to-Javascript compiler and development mode that helps you debug your GWT applications
  • 6. GWT SDK & Tools GWT SDK: contains Java API libraries, compiler, development server and tools Plugin for Eclipse: provides IDE support for GWT and App Engine web projects Some other tools: GWT Designer Speed Tracker Maven plugins
  • 7. Two modes of running GWT App Development mode (hosted mode) GWT application is run as Java bytecode within JVM Take advantage of Java debugging Production mode (web mode) Your GWT application is run as pure Javascript and HTML compiled from original Java source code End user will only see the web mode version of your application
  • 8. Why GWT? Static type checking in Java language boots productivity while reducing errors Easily caught common Javascript errors typos, type mismatches, ... Take advantage of Java refactoring, code completion, ... Java-based Object-Oriented designs are easier to communicate and understand.
  • 9. Why GWT? No need to write “excellent” Javascript code Leverage your Java programming knowledge No need to take care of browser incompatibilities and quirks GWT compiler handles them Support browser history, backward, forward Use Java API to manipulate DOM Take advantage from rich built-in Widgets
  • 10. Why GWT? Leverage various tools of Java programming for writing, debugging, testing Ex: Eclipse, IntelliJ, Netbeans JUnit integration Internationalization
  • 12. GWT Architecture Overview GWT Java-to-Javascript compiler Translates Java source code to Javascript code GWT Hosted Web Browser Let you run and debug your GWT application in development mode, where your code run as Java bytecode within JVM JRE emulation library A small subset of JRE to handle the Java to Javascript conversion. This of the JRE emulation library as representing the Javascript capabilities GWT Web UI class library A set of custom interfaces and classes for creating widgets.
  • 14. GWT User Interface GWT user interface classes are similar to those in existing UI frameworks such as Swing and SWT. GWT widgets are rendered using dynamically-created HTML rather than pixel-oriented graphics While GWT provides access to the browser's DOM directly using the DOM package, it is far easier to use classes from the Widget hierarchy The Widget classes make it easier to quickly build interfaces that will work correctly on all browsers.
  • 15. Widgets Library Widgets Library Images
  • 17. Widgets Library Widgets Library Images
  • 18. Event Handler Events in GWT use the handler model similar to other user interface frameworks A handler interface defines one or more methods that the widget calls to announce an event A class wishing to receive events of a particular type implements the associated handler interface and then passes a reference to itself to the widget to subscribe to a set of events.
  • 19. Event Handler Example public void anonClickHandlerExample() { Button b = new Button(&quot;Click Me&quot;); b.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // handle the click event } }); }
  • 20. Apply styles GWT applications use CSS for visual styling Update styles dynamically in Java code Associate style sheets with the project Using a <link> tag in the host HTML page. Using the <stylesheet> element in the module XML file.
  • 22. GWT Remote Procedure Call Mechanism for interacting with server by invoking a method Ex: fetching data from server GWT RPC makes it easy for the client and server to pass Java objects back and forth over HTTP GWT provides serialization mechanism to bridge between client and server Any object that needs to send is a GWT Serialization type Proper use of GWT RPC can allow you to develop an application where all the UI logic resides on the client, leaving business logic on the server) Resulting in an application with greatly improved performance, reduced bandwidth, and reduced web server load
  • 23. GWT RPC plumbing architecture
  • 24. Implementing GWT RPC Define an interface for your service that extends RemoteService and lists all RPC method called “Synchronous Interface” Implement the service at server-side This class extends RemoteServiceServlet and implement the created interface Define an asynchronous interface to your service to be called from the client-side code Based on original service interface Require caller to pass callback object that can be notified when async call completes.
  • 25. Serializable Types GWT RPC method parameters and return types must be serializable These values will be transmitted across network between client and server Java data types are already serializable Primitive, such as char, byte, short, int, long, boolean, float, or double. String, Date or primitive wrapper: Character, Integer, Byte, Double, … Array of serializable types Serializable user-defined class The type has at least one serializable subclass
  • 26. Handling Exception Making RPCs opens up the possibility of a variety of errors Networks fail, servers crash, and problems occur while processing a server call. GWT lets you handle these conditions in terms of Java exceptions Caller should implement AsyncCallBack.onFailure(Throwable) to handle exception
  • 28. GWT History Mechanism GWT applications use “history token” to help Ajax developer activate browser history The token will be saved in browser history as a URL fragment Ex: http://www.example.com/historyexample/HistoryExample.html#page1 To enable history to your Ajax Add a history token to the history stack when you want to enable history event Create an object that implements the ValueChangeHandler interface, parses new token and changes the application state to match
  • 29. GWT History GWT history demo
  • 31. Internationalization GWT offers multiple internationalization techniques Static String Internationalization Dynamic String Internationalization Static String Internationalization Extends Constants Interface Extends Message Interface Use properties files Dynamic String Internationalization
  • 34. JUnit Testing GWT provides integration with the popular JUnit unit testing framework GWT allows JUnit test cases to run in either development mode or production mode.
  • 37. Why JSNI? Sometimes it's very useful to mix handwritten Javascript to Java source code Ex: access low-level browser functionality not exposed by the GWT API You can use JSNI to: Implement a Java method directly in JavaScript Wrap type-safe Java method signatures around existing JavaScript Call from JavaScript code into Java code and vice-versa Throw exceptions across Java/JavaScript boundaries Read and write Java fields from JavaScript Use development mode to debug both Java source (with a Java debugger) and JavaScript (with a script debugger)
  • 39. Resources http://code.google.com/webtoolkit/ Main site for GWT http://googlewebtoolkit.blogspot.com/ http://developerlife.com