• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Google Web Toolkit: An Introduction
 

Google Web Toolkit: An Introduction

on

  • 729 views

 

Statistics

Views

Total Views
729
Views on SlideShare
728
Embed Views
1

Actions

Likes
0
Downloads
7
Comments
0

1 Embed 1

http://www.slideshare.net 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Google Web Toolkit: An Introduction Google Web Toolkit: An Introduction Presentation Transcript

    • Google Web Toolkit: An Introduction David Geary President Clarity Training, Inc. clarity.training@gmail.com Copyright © Clarity Training, Inc. 2008-2009
    • David Geary JSF Copyright © Clarity Training, Inc. 2008-2009
    • In this session, you will learn  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 Copyright © Clarity Training, Inc. 2008-2009
    • Agenda  Introduction  Implementing applications  API overview: widgets on the client  On the server: services  Integrating JavaScript Copyright © Clarity Training, Inc. 2008-2009
    • Old problems, new solutions Copyright © Clarity Training, Inc. 2008-2009
    • Code for this talk is from... coolandusefulgwt.com Copyright © Clarity Training, Inc. 2008-2009
    • The premise  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... Copyright © Clarity Training, Inc. 2008-2009
    • The promise  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 Copyright © Clarity Training, Inc. 2008-2009
    • Top 5 features  Application generator for a quick start  Convention over configuration  Instant turnaround after changes  Non-Ajax Ajax  Awesome productivity Copyright © Clarity Training, Inc. 2008-2009
    • The GWT sweet spot  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 Copyright © Clarity Training, Inc. 2008-2009
    • Agenda  Introduction  Implementing applications  API overview: widgets on the client  On the server: services  Integrating JavaScript Copyright © Clarity Training, Inc. 2008-2009
    • Client-side code  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 Copyright © Clarity Training, Inc. 2008-2009
    • Server-side code  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 Copyright © Clarity Training, Inc. 2008-2009
    • Get started quickly  Project generator (Eclipse)  Application generator  I18N generator  Test generator Copyright © Clarity Training, Inc. 2008-2009
    • Demonstration Copyright © Clarity Training, Inc. 2008-2009
    • Agenda  Introduction  Implementing applications  API overview: widgets on the client  On the server: services  Integrating JavaScript Copyright © Clarity Training, Inc. 2008-2009
    • Widget hierarchy (partial) Copyright © Clarity Training, Inc. 2008-2009
    • Commonly used widgets  The basic widgets • Label, Image, TextBox, Button, Hyperlink • FileUpload, Tree, TabPanel, Popup, FlexTable  Panels • HorizontalPanel and VerticalPanel  Listeners • ClickListener, MouseListener, FocusListener, ... Copyright © Clarity Training, Inc. 2008-2009
    • Demonstration Copyright © Clarity Training, Inc. 2008-2009
    • Agenda  Introduction  Implementing applications  API overview: widgets on the client  On the server: services  Integrating JavaScript Copyright © Clarity Training, Inc. 2008-2009
    • Invoking server-side code Two interfaces: • Remote interface • Asynchronous interface One class: • Remote servlet class 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); } Copyright © Clarity Training, Inc. 2008-2009
    • The servlet <servlet path=”/weatherService” class=”example.server.WeatherServiceImpl”/> public class WeatherServiceImpl extends RemoteServiceServlet implements WeatherService { public String getWeatherForZip(String zip, boolean isCelsius) { // invoke Yahoo! weather web service } } 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”); ... 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()); } }); Copyright © Clarity Training, Inc. 2008-2009
    • Demonstration Copyright © Clarity Training, Inc. 2008-2009
    • Agenda  Introduction  Implementing applications  API overview: widgets on the client  On the server: services  Integrating JavaScript 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); }-*/; ... } Copyright © Clarity Training, Inc. 2008-2009
    • Demonstration Copyright © Clarity Training, Inc. 2008-2009
    • Questions Copyright © Clarity Training, Inc. 2008-2009