google web toolkit: an introduction - java conference
TRANSCRIPT
![Page 1: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/1.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Google Web Toolkit: An Introduction
David GearyPresidentClarity Training, Inc. [email protected]
![Page 2: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/2.jpg)
Copyright © Clarity Training, Inc. 2008-2009
JSF
David Geary
![Page 3: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/3.jpg)
Copyright © Clarity Training, Inc. 2008-2009
What GWT is How to get started quickly with GWT How to implement I18N, using CSS How to implement server side services How to integrate JavaScript
In this session, you will learn
![Page 4: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/4.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Introduction Implementing applications API overview: widgets on the client On the server: services Integrating JavaScript
Agenda
![Page 5: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/5.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Old problems, new solutions
![Page 6: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/6.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Code for this talk is from...
coolandusefulgwt.com
![Page 7: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/7.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Ajax is hard• It requires:
expertise in JavaScript a mixture of disparate technologies integration of client- and server-code
Ajax libraries make things easier, but...
The premise
![Page 8: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/8.jpg)
Copyright © Clarity Training, Inc. 2008-2009
You can develop Ajax-enabled web apps in Java• Implement client-side UI in pure Java• Very little knowledge of JavaScript required• Familiar idioms from the AWT and Swing
The promise
![Page 9: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/9.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Application generator for a quick startConvention over configurationInstant turnaround after changesNon-Ajax AjaxAwesome productivity
Top 5 features
![Page 10: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/10.jpg)
Copyright © Clarity Training, Inc. 2008-2009
GWT is not for everyone. Here’s the sweet spot:• Swing-like apps that run in a browser• Java developers who’ve used a desktop ui framework, or at least a
component-based framework like JSF
The GWT sweet spot
![Page 11: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/11.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Introduction Implementing applications API overview: widgets on the client On the server: services Integrating JavaScript
Agenda
![Page 12: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/12.jpg)
Copyright © Clarity Training, Inc. 2008-2009
You implement user interfaces in pure Java• Albeit, with a limited subset of Java• Selected choices from java.lang and java.util
In Hosted mode, your code runs in the JVM• Use your favorite Java debugger
In Web mode: JavaScript runs in the browser• GWT compiles Java to JavaScript
Client-side code
![Page 13: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/13.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Server-side code is written in Java• All of Java is available• Code is compiled normally
Server-side code is packaged in services• Remote procedure calls from client-server• Services are accessed with a remote servlet
Server-side code
![Page 14: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/14.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Project generator (Eclipse) Application generator I18N generator Test generator
Get started quickly
![Page 15: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/15.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Demonstration
![Page 16: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/16.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Introduction Implementing applications API overview: widgets on the client On the server: services Integrating JavaScript
Agenda
![Page 17: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/17.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Widget hierarchy (partial)
![Page 18: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/18.jpg)
Copyright © Clarity Training, Inc. 2008-2009
The basic widgets• Label, Image, TextBox, Button, Hyperlink• FileUpload, Tree, TabPanel, Popup, FlexTable
Panels• HorizontalPanel and VerticalPanel
Listeners• ClickListener, MouseListener, FocusListener, ...
Commonly used widgets
![Page 19: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/19.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Demonstration
![Page 20: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/20.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Introduction Implementing applications API overview: widgets on the client On the server: services Integrating JavaScript
Agenda
![Page 21: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/21.jpg)
Copyright © Clarity Training, Inc. 2008-2009
� Two interfaces:• Remote interface• Asynchronous interface
� One class:• Remote servlet class
Invoking server-side code
![Page 22: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/22.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Remote and Asynch interfaces
public interface WeatherService extends RemoteService { public String getWeatherForZip(String zip, boolean isCelsius);}
public interface WeatherServiceAsync { public void getWeatherForZip(String zip, boolean isCelsius, AsyncCallback callback);}
![Page 23: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/23.jpg)
Copyright © Clarity Training, Inc. 2008-2009
The servlet
public class WeatherServiceImpl extends RemoteServiceServlet implements WeatherService {
public String getWeatherForZip(String zip, boolean isCelsius) { // invoke Yahoo! weather web service }}
<servlet path=”/weatherService” class=”example.server.WeatherServiceImpl”/>
![Page 24: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/24.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Creating the weather service
// Get a reference to the service... WeatherServiceAsync service = (WeatherServiceAsync) GWT.create(WeatherService.class);
// Set the entry point for the service...((ServiceDefTarget)service).setServiceEntryPoint (GWT.getModuleBaseURL() + “/weatherService”);
...
![Page 25: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/25.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Using the weather service
...
// Invoke the service with an asynchronous callback service.getWeatherForZip("80132", true, new AsyncCallback() { public void onSuccess(Object result) { displayHTML(result); } public void onFailure(Throwable t) { showAlert("Remote service call failed: " + t.getMessage()); } });
![Page 26: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/26.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Demonstration
![Page 27: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/27.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Introduction Implementing applications API overview: widgets on the client On the server: services Integrating JavaScript
Agenda
![Page 28: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/28.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Integrating Script.aculo.us effects
public class MyApp implements EntryPoint { ... public void onModuleLoad() { Label errorMessage = new Label(”Get it together!”); ... errorMessage.setVisible(false); ... applyEffect(”Shake”, errorMessage.getElement()); } ... private native void applyEffect(String effect, Element e) /*-{ $wnd.Effect[effect](e); }-*/; ...}
![Page 29: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/29.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Demonstration
![Page 30: Google Web Toolkit: An Introduction - Java Conference](https://reader035.vdocuments.mx/reader035/viewer/2022081622/613d5093736caf36b75bdd57/html5/thumbnails/30.jpg)
Copyright © Clarity Training, Inc. 2008-2009
Questions