Transcript gwt
Google Web Toolkit
What it offers us
What is it?
Java to Javascript “compiler”
Web browser emulator
Java and Javascript libraries
Complete “AJAX” programming
environment
Used in Google Calendar, Google Mashup
Editor, etc.
Advantages over Flash
We already know Java.
Free (both in “freedom” and “beer” senses)
to develop, free to deploy.
No plugins to manage, uses browser’s builtin Javascript.
Advantages over other AJAX
toolkits
Don’t need to know Javascript.
Browser dependencies handled
automagically.
Debug in Java using Eclipse or other Java
debugger.
Active Google Code developer community.
Other nifty features
Supports Eclipse, Ant, Junit.
Uses any Servlet engine you like, such as
Tomcat or Jetty - builds .war file for
deployment.
Now the down side
The client side uses a subset of the JRE
library.
The client side only supports Java 1.4
Can’t do “flashy” stuff.
It’s not Swing.
You probably need to know a bit of CSS.
Had to write my own “pseudo Server Push”.
Client Side Coding
Keep the Client Side as small as possible.
“Render” Playlist object to an array of Strings
on the server instead of sending the whole
class.
Keep whole lists (like Playlists) on the server,
send a page full at a time to the Client on
demand.
GWT AbstractImagePrototype a mixed
blessing.
The first “A” in AJAX is
“Asynchronous”
Server calls are all asynchronous.
Javascript is single threaded, so process
callbacks as quickly as possible.
Slight quirk - you define an Interface that
extends “RemoteInterface” for the server
side, and another interface for the client.
Building User Interfaces
Very similar to Swing
Widgets and Panels.
Panels perform layout for Widgets.
You can subclass widgets.
Your code can set the CSS style name for a
component.
Before we look at what I did
Let’s look at some good stuff.
Goals of my demo
Prove that I could get information out of the
database and display it on a web browser.
Prove I could have dynamic content that
updated/added/removed automatically.
Prove that the server could send Java objects to
the client.
Prove that I could debug the client code in Java.
Secondary Goals
To not have to learn Javascript
To use as little CSS as possible.
Before we look at the real app
and code…
I wasn’t trying to make it pretty, just
determine if things were possible or not.
I suck at drawing programs.
This laptop is old and slow.
Mission Accomplished!