20
Google Web Toolkit An Overview By Shauvik Roy Choudhary

Google Web Toolkit An Overview

Embed Size (px)

DESCRIPTION

Google Web Toolkit An Overview. By Shauvik Roy Choudhary. Agenda. GWT Basics User Interfaces Remote Procedure Calls (RPCs) JavaScript Native Interface (JSNI) The GWT Project. GWT Basics. What is GWT?. Java software development framework that makes writing AJAX applications easy - PowerPoint PPT Presentation

Citation preview

Page 1: Google Web Toolkit An Overview

Google Web Toolkit An Overview

ByShauvik Roy Choudhary

Page 2: Google Web Toolkit An Overview

Agenda GWT Basics User Interfaces Remote Procedure Calls (RPCs) JavaScript Native Interface (JSNI) The GWT Project

Page 3: Google Web Toolkit An Overview

GWT Basics

Page 4: Google Web Toolkit An Overview

What is GWT? Java software development framework

that makes writing AJAX applications easy Develop and debug AJAX applications in

the Java language Java-to-JavaScript compiler and a special

web browser The compiler translates your Java

application to browser-compliant JavaScript and HTML

Page 5: Google Web Toolkit An Overview

Two Modes of Running Hosted mode

Application runs as Java bytecode within the Java Virtual Machine (JVM)

Used for Development because running in the JVM means you can take advantage of Java's debugging facilities

Web mode Application runs as pure JavaScript and

HTML, compiled with the Java-to-JavaScript compiler

End users will only see this mode

Page 6: Google Web Toolkit An Overview

Why use Java ? Static type checking boosts productivity

while reducing errors. Common JavaScript errors (typos, type

mismatches) are easily caught at compile time

Code prompting/completion Automated Java refactoring Java-based OO designs are easier to

communicate and understand

Page 7: Google Web Toolkit An Overview

Why GWT ? No need to

learn/use JavaScript language learn/use DOM APIs handle browser incompatibilities and quirks handle forward/backward buttons build commonly used Widgets

Leverage various tools of Java programming language for writing/debugging/testing

JUnit integration Internationalization

Page 8: Google Web Toolkit An Overview

GWT Architecture

Page 9: Google Web Toolkit An Overview

Building User Interfaces

Page 10: Google Web Toolkit An Overview

Building User Interfaces GWT User Interface Classes Lots of GWT Widgets Custom Composite Widgets Event Handling

Listener interface model Styling through CSS

Dynamically add/remove styles

Page 11: Google Web Toolkit An Overview

Remote Procedure Call (RPC)

Page 12: Google Web Toolkit An Overview

What is and Why GWT RPC? Mechanism for interacting with the server

by invoking a method

Makes it easy for the client and server to pass Java objects back and forth over HTTP

When used properly, RPCs give you the opportunity to move all of your UI logic to the client (leaving business logic on the server)

Page 13: Google Web Toolkit An Overview

RPC Plumbing Architecture

Page 14: Google Web Toolkit An Overview

Implementing a GWT RPC Write two service interface's (client & server)

Synchronous interface Asynchronous interface - has to pass async.

callback object Implement the service at the server side

Service class implements Service interface and extends RemoteServiceServlet class

Configure the service in the module configuration file Needed for running the app in hosted mode

Make a call from the client

Page 15: Google Web Toolkit An Overview

JavaScript Native JavaScript Native Interface (JSNI)

Page 16: Google Web Toolkit An Overview

Why JSNI? Sometimes it's very useful to mix

handwritten JavaScript into your Java source code

Leverage various existing JavaScript toolkits Dojo toolkits, Prototype, Rico, etc.

Should be used sparingly JSNI code is less portable across browsers, more

likely to leak memory, less amenable to Java tools, and hard for the compiler to optimize

Web equivalent of inline assembly code

Page 17: Google Web Toolkit An Overview

GWT Module Configuration

Page 18: Google Web Toolkit An Overview

Configuration Settings of a GWT Project (*.gwt.xml) Inherited modules An entry point class name Source path entries Public path entries Deferred binding rules, including

property providers and class generators

Page 19: Google Web Toolkit An Overview

Project Structure Overlaid into Java Packages Standard GWT Project layout

com/example/cal/ - The project root package contains module XML files

com/example/cal/client/ - Client-side source files and subpackages

com/example/cal/server/ - Server-side code and subpackages

com/example/cal/public/ - Static resources that can be served publicly

Page 20: Google Web Toolkit An Overview

References Links

http://code.google.com/webtoolkit/ http://www.onjava.com/pub/a/onjava/2006/05/31/

working-with-google-web-toolkit.html http://www.javapassion.com

Books GWT Java Ajax Programming

by Prabhakar Chaganti [Packt Publishing] The Google Web Toolkit

by Bruce Johnson and Joel Webber [Addison-Wesley]