Tài liệu GWT in Action doc

631 4.6K 2
Tài liệu GWT in Action doc

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

www.it-ebooks.info GWT in Action www.it-ebooks.info www.it-ebooks.info GWT in Action EASY AJAX WITH THE GOOGLE WEB TOOLKIT ROBERT HANSON ADAM TACY MANNING Greenwich (74° w. long.) www.it-ebooks.info For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact: Special Sales Department Manning Publications Co. Sound View Court 3B fax: (609) 877-8256 Greenwich, CT 06830 email: orders@manning.com ©2007 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Manning Publications Co. Copyeditor: Tiffany Taylor Sound View Court 3B Typesetters: Gordan Salinovic Greenwich, CT 06830 Cover designer: Leslie Haimes ISBN 1-933988-23-1 Printed in the United States of America 12345678910–MAL –13121110090807 www.it-ebooks.info To my son, David Thank you for letting me shorten playtime so many times, so that Daddy could work on his book. —RH To my parents Everything I have achieved is because of something you did for me. Thank you. —AT www.it-ebooks.info www.it-ebooks.info vii brief contents PART 1GETTING STARTED 1 1 ■ Introducing GWT 3 2 ■ Creating the default application 38 3 ■ Advancing to your own application 64 PART 2BUILDING USER INTERFACES 107 4 ■ Working with widgets 109 5 ■ Working with panels 157 6 ■ Handling events 192 7 ■ Creating composite widgets 246 8 ■ Building JSNI components 277 9 ■ Modularizing an application 317 PART 3ADVANCED TECHNIQUES 345 10 ■ Communicating with GWT-RPC 347 11 ■ Examining client-side RPC architecture 375 12 ■ Classic Ajax and HTML forms 409 www.it-ebooks.info viii BRIEF CONTENTS 13 ■ Achieving interoperability with JSON 442 14 ■ Automatically generating new code 471 15 ■ Changing applications based on GWT properties 494 PART 4COMPLETING THE UNDERSTANDING 525 16 ■ Testing and deploying GWT applications 527 17 ■ Peeking into how GWT works 555 www.it-ebooks.info ix contents preface xix acknowledgments xxi about this book xxiii about the title xxx about the cover illustration xxxi PART 1GETTING STARTED 1 1 Introducing GWT 3 1.1 A walk through GWT 5 Explaining GWT's Java-to-JavaScript compiler 6 ■ Using JSNI to execute JavaScript from Java 8 ■ Accessing the JRE emulation library 10 ■ Understanding GWT's widget and panel library 12 ■ Examining GWT’s internationalization and configuration tools 14 ■ Calling remote procedures with GWT 16 ■ Investigating GWT’s XML parser 20 ■ Managing the browser history 21 ■ Introducing GWT’s JUnit integration 22 1.2 GWT vs. other solutions 23 GWT vs. Swing 25 ■ GWT vs. Echo2 26 ■ GWT vs. JavaServer Faces 27 ■ GWT vs. Ruby on Rails 29 www.it-ebooks.info [...]... your GWT code 212 ■ Preventing default browser event handling 216 6.3 Handling standard browser events 216 Reacting to change 218 ■ Clicking around 221 ■ Gaining/ Losing focus 222 ■ Capturing keyboard inputs 223 Loading images 223 ■ Managing mouse inputs 224 ■ Scrolling 224 ■ Window resize events 226 ■ Window close events 227 6.4 Handling other event types 231 Handling forms 231 Reacting to closing... 371 374 Examining client-side RPC architecture 375 11.1 Structuring the client code 376 Encapsulating the Server Status component 376 ■ Encapsulating remote calls in a façade 382 ■ Callback routine using the Command pattern 384 11.2 Examining different polling techniques 392 Understanding polling issues 392 Implementing a continuously updating component 393 ■ Emulating server-push by blocking server... value 522 ■ Building the code 522 15.6 Summary 523 PART 4 COMPLETING THE UNDERSTANDING 525 16 Testing and deploying GWT applications 527 16.1 Testing GWT code using JUnit 528 Overview of JUnit for GWT developers 529 ■ Creating a new test case 534 ■ Testing asynchronous code 537 16.2 Deploying GWT applications Organizing your project 16.3 Summary 540 554 www.it-ebooks.info ■ 539 Installing RPC servlets... Building your first GWT application 30 Building and running an example application Building Tic-Tac-Toe with GWT 32 1.4 2 Summary 30 37 Creating the default application 38 2.1 2.2 The GWT application development lifecycle Stage 1: Creating a GWT application 44 39 Creating the project 47 ■ Creating an application 50 Setting up internationalization 54 ■ Implementing internationalization 56 ■ Creating... 317 9.1 Creating a modularization structure 318 Modularization in GWT 319 ■ Including other modules in an application 321 ■ Setting source and other resource paths 325 ■ Defining an application’s server resources 326 ■ Managing an application’s GWT properties 327 ■ Replacing classes based on property values 332 ■ Registering generators in the XML module file 333 ■ Injecting resources into an application... ■ Importing into your IDE 59 2.3 3 Summary 63 Advancing to your own application 3.1 3.2 64 Describing the application example 65 Stage 2: Developing your application 67 Implementing internationalization 68 ■ Constructing the application 72 ■ Applying styling 83 3.3 Stage 3: Testing and debugging in hosted mode 86 Preparing for hosted mode 86 Running the Dashboard in hosted mode 90 ■ Debugging the Dashboard... www.it-ebooks.info 99 CONTENTS PART 2 BUILDING USER INTERFACES 107 4 Working with widgets 109 4.1 What is a widget? 111 Using widgets as Java objects 112 Considering widgets as DOM elements 113 4.2 The standard GWT widgets 115 Interacting with the basic widgets 118 ■ Displaying text on the application 131 ■ Grabbing the user’s interaction using focus widgets 133 ■ Getting user input through text input 139... technologies Following the introduction, this part of the book provides instruction for getting your first GWT application up and running, using the GWT commandline tools to generate skeleton code Finally, we’ll take a detailed look at the skeleton code and, more important, explain how to extend it www.it-ebooks.info www.it-ebooks.info Introducing GWT This chapter covers ■ ■ High-level overview of GWT s toolset... Listening to FormPanel events 428 ■ Altering the FormPanel target 429 ■ Using the various form controls 432 12.3 13 Summary 439 Achieving interoperability with JSON 442 13.1 Introducing JavaScript Object Notation (JSON) 443 Understanding the JSON data format 443 Using JSONParser to parse JSON messages 445 13.2 Examining GWT s JSON data objects 445 Introducing the JSONValue object 445 ■ Examining basic... internationalization in full 502 Using static-string internationalization 503 Using dynamic string internationalization 516 15.4 Altering the application for the locale 518 Implementing the default component 518 Locale-specific classes 519 15.5 Implementing user-defined properties 520 Defining user-specified properties 521 ■ Defining a user-specified property provider 521 ■ Checking the provided property . www.it-ebooks.info GWT in Action www.it-ebooks.info www.it-ebooks.info GWT in Action EASY AJAX WITH THE GOOGLE WEB TOOLKIT ROBERT HANSON ADAM TACY MANNING Greenwich (74°. 14 ■ Calling remote procedures with GWT 16 ■ Investigating GWT s XML parser 20 ■ Managing the browser history 21 ■ Introducing GWT s JUnit integration

Ngày đăng: 18/02/2014, 06:20

Từ khóa liên quan

Mục lục

  • GWT in Action

    • brief contents

    • contents

    • preface

    • acknowledgments

    • about this book

    • about the title

    • about the cover illustration

    • Getting started

      • Introducing GWT

        • 1.1 A walk through GWT

          • 1.1.1 Explaining GWT's Java-to-JavaScript compiler

          • 1.1.2 Using JSNI to execute JavaScript from Java

          • 1.1.3 Accessing the JRE emulation library

          • 1.1.4 Understanding GWT's widget and panel library

          • 1.1.5 Examining GWT’s internationalization and configuration tools

          • 1.1.6 Calling remote procedures with GWT

          • 1.1.7 Investigating GWT’s XML parser

          • 1.1.8 Managing the browser history

          • 1.1.9 Introducing GWT’s JUnit integration

        • 1.2 GWT vs. other solutions

          • 1.2.1 GWT vs. Swing

          • 1.2.2 GWT vs. Echo2

          • 1.2.3 GWT vs. JavaServer Faces

          • 1.2.4 GWT vs. Ruby on Rails

        • 1.3 Building your first GWT application

          • 1.3.1 Building and running an example application

          • 1.3.2 Building Tic-Tac-Toe with GWT

        • 1.4 Summary

      • Creating the default application

        • 2.1 The GWT application development lifecycle

        • 2.2 Stage 1: Creating a GWT application

          • 2.2.1 Creating the project

          • 2.2.2 Creating an application

          • 2.2.3 Setting up internationalization

          • 2.2.4 Implementing internationalization

          • 2.2.5 Creating unit test cases

          • 2.2.6 Importing into your IDE

        • 2.3 Summary

      • Advancing to your own application

        • 3.1 Describing the application example

        • 3.2 Stage 2: Developing your application

          • 3.2.1 Implementing internationalization

          • 3.2.2 Constructing the application

          • 3.2.3 Applying styling

        • 3.3 Stage 3: Testing and debugging in hosted mode

          • 3.3.1 Preparing for hosted mode

          • 3.3.2 Running the Dashboard in hosted mode

          • 3.3.3 Debugging the Dashboard in hosted mode through Eclipse

        • 3.4 Stage 4: Compiling the code

          • 3.4.1 Compiling the code/preparing for web mode

          • 3.4.2 Viewing the compilation results

        • 3.5 Stage 5: Deploying the code

          • 3.5.1 Deploying to a web server

          • 3.5.2 Deploying to a filesystem

        • 3.6 Stage 6: Running in web mode

        • 3.7 Implementing application logging

          • 3.7.1 Logging information on the client-side

          • 3.7.2 Logging information on the server-side

        • 3.8 Summary

    • Building user interfaces

      • Working with widgets

        • 4.1 What is a widget?

          • 4.1.1 Using widgets as Java objects

          • 4.1.2 Considering widgets as DOM elements

        • 4.2 The standard GWT widgets

          • 4.2.1 Interacting with the basic widgets

          • 4.2.2 Displaying text on the application

          • 4.2.3 Grabbing the user’s interaction using focus widgets

          • 4.2.4 Getting user input through text input

        • 4.3 Creating new widgets

          • 4.3.1 Creating new widgets by manipulating the DOM

          • 4.3.2 Creating new widgets by extending existing widgets

        • 4.4 Developing the Dashboard’s ToggleMenuItem widget

          • 4.4.1 Building the TwoComponentMenuItem

          • 4.4.2 Building the ToggleMenuItem

        • 4.5 Summary

      • Working with panels

        • 5.1 What is a panel?

          • 5.1.1 Using panels as Java Objects

          • 5.1.2 Considering panels as DOM elements

        • 5.2 The standard GWT panels

          • 5.2.1 Interacting with simple panels

          • 5.2.2 Considering more complex panels

          • 5.2.3 Considering HTML table-based panels

          • 5.2.4 Considering composite panels

          • 5.2.5 Splitting panels

        • 5.3 Creating new panels

          • 5.3.1 Creating a new panel from scratch

          • 5.3.2 Creating a new panel by extending an existing panel

        • 5.4 Creating the Dashboard panel

        • 5.5 Summary

      • Handling events

        • 6.1 Exploring events

          • 6.1.1 Identifying event model browser differences

          • 6.1.2 Understanding the GWT event model

        • 6.2 Listening to events

          • 6.2.1 Sinking events

          • 6.2.2 Managing sunk events with the onBrowserEvent() method

          • 6.2.3 Linking sunk events to the onBrowserEvent() method

          • 6.2.4 Previewing events

          • 6.2.5 Handling events by extending the listener classes

          • 6.2.6 Moving events further into your GWT code

          • 6.2.7 Preventing default browser event handling

        • 6.3 Handling standard browser events

          • 6.3.1 Reacting to change

          • 6.3.2 Clicking around

          • 6.3.3 Gaining/Losing focus

          • 6.3.4 Capturing keyboard inputs

          • 6.3.5 Loading images

          • 6.3.6 Managing mouse inputs

          • 6.3.7 Scrolling

          • 6.3.8 Window resize events

          • 6.3.9 Window close events

        • 6.4 Handling other event types

          • 6.4.1 Handling forms

          • 6.4.2 Reacting to closing pop-ups

          • 6.4.3 Tab events

          • 6.4.4 Tabling events

          • 6.4.5 Tree events

        • 6.5 Implementing drag-and-drop

          • 6.5.1 Implementing the drag part

          • 6.5.2 Implementing the drop part

        • 6.6 Summary

      • Creating composite widgets

        • 7.1 What is a composite widget?

        • 7.2 Composite widget development steps

        • 7.3 Building the editable label

          • 7.3.1 Step 1: Identifying the components

          • 7.3.2 Step 2: Choosing the panel layout and structure

          • 7.3.3 Step 3: Implementing the right GWT Java interfaces

          • 7.3.4 Step 4: Building the composite widget

          • 7.3.5 Step 5: Styling the composite widget

        • 7.4 Creating a composite widget from other composite widgets

          • 7.4.1 Creating a slider

          • 7.4.2 Constructing the ColourPicker composite

        • 7.5 Creating the Dashboard composite

        • 7.6 Summary

      • Building JSNI components

        • 8.1 Introducing JavaScript Native Interface (JSNI)

        • 8.1.1 Understanding JSNI

        • 8.2 Communicating using JSNI

          • 8.2.1 Chatting to the browser via GWT Java

          • 8.2.2 Chatting to the browser via JavaScript

          • 8.2.3 Talking to a GWT application via a JavaScript API

          • 8.2.4 Talking between GWT applications

        • 8.3 Loading a JavaScript library

          • 8.3.1 Using HTML to load a JavaScript library

          • 8.3.2 Using the module XML to load a JavaScript library

        • 8.4 Wrapping a simple JavaScript library

          • 8.4.1 Accessing the loaded JavaScript library

          • 8.4.2 Using the widget in an application

        • 8.5 Wrapping a complex JavaScript library

          • 8.5.1 Generating the classes

          • 8.5.2 Keeping JavaScript objects as Java objects

          • 8.5.3 Calling user-defined code from a library

          • 8.5.4 Using a complex wrapped widget in an application

        • 8.6 Summary

      • Modularizing an application

        • 9.1 Creating a modularization structure

          • 9.1.1 Modularization in GWT

          • 9.1.2 Including other modules in an application

          • 9.1.3 Setting source and other resource paths

          • 9.1.4 Defining an application’s server resources

          • 9.1.5 Managing an application’s GWT properties

          • 9.1.6 Replacing classes based on property values

          • 9.1.7 Registering generators in the XML module file

          • 9.1.8 Injecting resources into an application at runtime

          • 9.1.9 Setting an application’s entry point

          • 9.1.10 The Dashboard’s module XML file

        • 9.2 Including third-party modules

        • 9.3 Packaging your own modules

        • 9.4 Creating the Java package structure

        • 9.5 Summary

    • Advanced techniques

      • Communicating with GWT-RPC

        • 10.1 Underlying RPC concepts

          • 10.1.1 Understanding asynchronous communication

          • 10.1.2 Restrictions for communicating with remote servers

          • 10.1.3 Creating the Server Status project

        • 10.2 Implementing GWT-RPC

          • 10.2.1 Understanding serializable data objects

          • 10.2.2 Defining the GWT-RPC service

          • 10.2.3 Preparing the client side of a GWT-RPC call

          • 10.2.4 Calling the remote server service

        • 10.3 Project summary

          • 10.3.1 Project overview

          • 10.3.2 Server-side service implementation

          • 10.3.3 Calling the service from the client

        • 10.4 Summary

      • Examining client-side RPC architecture

        • 11.1 Structuring the client code

          • 11.1.1 Encapsulating the Server Status component

          • 11.1.2 Encapsulating remote calls in a façade

          • 11.1.3 Callback routine using the Command pattern

        • 11.2 Examining different polling techniques

          • 11.2.1 Understanding polling issues

          • 11.2.2 Implementing a continuously updating component

          • 11.2.3 Emulating server-push by blocking server threads

        • 11.3 Writing custom field serializers

          • 11.3.1 Creating a custom field serializer class

          • 11.3.2 Implementing custom field serialization

        • 11.4 Summary

      • Classic Ajax and HTML forms

        • 12.1 Classic Ajax with RequestBuilder

          • 12.1.1 Examining HTTP methods

          • 12.1.2 Simple RPC with RequestBuilder

          • 12.1.3 Using RequestBuilder to load XML data

        • 12.2 Examining FormPanel basics

          • 12.2.1 Introducing the FormPanel

          • 12.2.2 Listening to FormPanel events

          • 12.2.3 Altering the FormPanel target

          • 12.2.4 Using the various form controls

        • 12.3 Summary

      • Achieving interoperability with JSON

        • 13.1 Introducing JavaScript Object Notation (JSON)

          • 13.1.1 Understanding the JSON data format

          • 13.1.2 Using JSONParser to parse JSON messages

        • 13.2 Examining GWT’s JSON data objects

          • 13.2.1 Introducing the JSONValue object

          • 13.2.2 Examining basic JSON types

          • 13.2.3 Storing JSONValue objects in a JSONArray

          • 13.2.4 Collecting JSONValue objects in a JSONObject

        • 13.3 Creating a search component using JSON

          • 13.3.1 Examining the Yahoo Search API

          • 13.3.2 Implementing the Yahoo search component

          • 13.3.3 Sending JSON data to the server

          • 13.3.4 Parsing and validating a JSON server response

        • 13.4 Implementing a Yahoo Search proxy service

          • 13.4.1 Using JSON with Java on the server

          • 13.4.2 Using JSON with Perl on the server

          • 13.4.3 Using JSON with Ruby on the server

        • 13.5 Summary

      • Automatically generating new code

        • 14.1 Generating new types

        • 14.2 Investigating GWT generators

          • 14.2.1 Basic generator code

        • 14.3 Creating a generator for the Dashboard

          • 14.3.1 Accessing the input class

          • 14.3.2 Accessing properties of the context

          • 14.3.3 Adding logging to a generator

          • 14.3.4 Generating the new type structure

          • 14.3.5 Creating the new class

          • 14.3.6 Using the classes that have been generated

        • 14.4 Summary

      • Changing applications based on GWT properties

        • 15.1 Quick summary of properties

        • 15.2 Managing browser differences

          • 15.2.1 How GWT manages browser differences

          • 15.2.2 Building the Flash widget

          • 15.2.3 Setting up the property replacement

        • 15.3 Supporting internationalization in full

          • 15.3.1 Using static-string internationalization

          • 15.3.2 Using dynamic string internationalization

        • 15.4 Altering the application for the locale

          • 15.4.1 Implementing the default component

          • 15.4.2 Locale-specific classes

        • 15.5 Implementing user-defined properties

          • 15.5.1 Defining user-specified properties

          • 15.5.2 Defining a user-specified property provider

          • 15.5.3 Checking the provided property value

          • 15.5.4 Building the code

        • 15.6 Summary

    • Completing the understanding

      • Testing and deploying GWT applications

        • 16.1 Testing GWT code using JUnit

          • 16.1.1 Overview of JUnit for GWT developers

          • 16.1.2 Creating a new test case

          • 16.1.3 Testing asynchronous code

        • 16.2 Deploying GWT applications

          • 16.2.1 Organizing your project

          • 16.2.2 Installing RPC servlets

        • 16.3 Summary

      • Peeking into how GWT works

        • 17.1 Examining the compilation process and output

          • 17.1.1 Investigating compilation

          • 17.1.2 Examining the output

        • 17.2 The GWT application-loading mechanism

          • 17.2.1 Legacy applications

          • 17.2.2 Standard applications

          • 17.2.3 Bootstrapping the standard application

          • 17.2.4 Cross-script applications

        • 17.3 Compiling Java to JavaScript

          • 17.3.1 Exploring the produced JavaScript

          • 17.3.2 Reviewing standard Java objects: the vector object

          • 17.3.3 Exploring program code as JavaScript

          • 17.3.4 Understanding the initialization code segment

        • 17.4 Summary

    • index

Tài liệu cùng người dùng

Tài liệu liên quan