GWT (Google Web Toolkit) Documentation

repository·main·Indexed 41 days ago

https://github.com/gwtproject/gwt-site

Official developer guides and reference materials for GWT. Covers architectural patterns like MVP, performance optimization via fragment merging, GSS migration, JsInterop, and advanced implementation details such as preventing DOM memory leaks and creating dynamic host pages using Java Servlets or JSP.

Tokens
233.8K
Snippets
491
Records
822
Agent score
100%

What's inside GWT

  1. Overview of building GWT apps with Polymer Elements

    main

    This tutorial demonstrates how to build a modern GWT application (specifically a TodoList app) by integrating JavaScript-based Web Components into a Java GWT environment.

    Key technologies involved:

    • Polymer: A JavaScript library for building web applications with Web Components.
    • Polymer Elements: A collection of widgets built with Polymer.
    • GWT-Polymer-Elements: A Java wrapper (provided by Vaadin) that uses JsInterop to allow Polymer Elements to be used within GWT projects.

    The tutorial covers two main approaches to integration:

    1. Classic approach: Using widgets via UiBinder.
    2. Modern approach: Using JsInterop elements.

    By following this guide, you will learn how to manage responsive layouts, style elements with UiBinder, handle events, and implement a basic data model within a GWT/Polymer hybrid architecture.

  2. Overview of GWT Tutorial Topics

    main

    GWT tutorials cover several core development areas. Depending on your goal, you can follow specific learning paths:

    • Core Application Development: Building a sample application (e.g., StockWatcher) from scratch, including UI construction with widgets/panels, client-side Java logic, debugging in development mode, CSS styling, and production compilation.
    • Client-Server Communication:
      • GWT RPC: Making asynchronous calls and serializing Java objects.
      • HTTP/JSON: Retrieving JSON or XML data via HTTP requests.
      • Cross-site requests: Handling Same Origin Policy (SOP) constraints when calling remote servers.
    • Internationalization (i18n): Using Static String Internationalization to translate the UI.
    • Testing: Implementing unit tests using JUnit.
    • Deployment: Deploying applications to Google App Engine.
    • Modern Web Development: Building responsive apps using Polymer Elements and JsInterop.
  3. Choose a server communication method in GWT

    main

    GWT provides two primary ways to interact with a backend server via HTTP:

    1. GWT RPC: A framework that allows you to transparently make calls to Java servlets. It handles low-level details like object serialization and uses deferred binding to generate efficient client and server-side code.
    2. Custom HTTP Requests: Use GWT's HTTP client classes (such as RequestBuilder) to build and send custom HTTP requests, which is useful for interacting with JSON APIs or third-party services.

    While GWT translates Java to JavaScript for the client, your server-side code remains standard Java. You can use any Java library on the server without restriction.

  4. Explore Real-World GWT Projects

    main

    To understand how GWT is used in complex, production-grade applications, you can examine various real-world implementations. Examples of projects built with GWT include:

    • ruxit: A cloud-based application performance management solution.
    • Cloudorado: A client-side cloud computing comparison tool.
    • Gae-Studio: A tool for optimizing and managing Google App Engine applications.
    • BookedIN: An online appointment booking system (uses GWTP).
    • Go Grid: A cloud computing infrastructure service provider.
    • Scenechronize: A production management web application for film and television.
    • Whirled: A social virtual world website with multiplayer games.
  5. Explore GWT development articles and tutorials

    main

    The GWT documentation site hosts a collection of articles covering various aspects of GWT development, ranging from architectural patterns to security and performance optimization.

    Key topics available include:

    • Architecture & Patterns: MVP design pattern for large-scale applications and using dynamic host pages for authentication.
    • Styling: Migrating CssResources from CSS to GSS.
    • Performance & Tooling: Fragment merging in the GWT compiler, Super Dev Mode, and optimizing for iOS.
    • Integration: Using GWT with Hibernate, JSON mashups, and accessing JavaScript frameworks via JsInterop.
    • Security & Testing: Secure coding practices for GWT applications and test-driven design methodologies.
    • Libraries: Using Elemental for lightweight web application building.

    For modern GWT development, external resources like 'Modern GWT, first steps' provide guidance on using gwt-maven-archetypes to initialize projects.

  6. Explore the GWT Developer Guide topics

    main

    The GWT Developer Guide covers the full lifecycle of web application development. Key areas include:

    Core Development

    • Organize Projects: Learn conventions for identifying code intended for the client browser, the server, or both.
    • Compile & Debug: Understand development and production modes.
    • Coding Basics: Learn GWT programming fundamentals.
    • Build User Interfaces: Work with widgets, panels, the DOM, events, CSS, declarative UI, and images.

    Security & Best Practices

    • Security for GWT Applications: Protect against JavaScript attacks.
    • Security: Safe HTML: Follow coding guidelines to prevent Cross-Site-Scripting (XSS) vulnerabilities.
    • Security: GWT RPC XSRF protection: Prevent Cross-Site Request Forgery (XSRF/CSRF) in GWT RPCs.
    • Accessibility: Use features that enable screen readers for visually impaired users.

    Advanced Features & Architecture

    • MVP Framework: Use Activities, Places, and the EventBus to structure your application.
    • RequestFactory: Create data-oriented services using RequestFactory and EntityProxy classes.
    • Internationalization: Use tools to internationalize applications and libraries.
    • Communicate with a Server: Explore different ways to communicate with a server via HTTP.
    • HTML5 Feature Support: Use GWT support for Storage, Canvas, Audio, Video, drag and drop, etc.

    Operations & Maintenance

    • Logging: Log events in client-side code.
    • Test with JUnit: Use JUnit and the Emma code coverage tool.
    • Deploy: Deploy both client- and server-side JavaScript.
    • Optimize: Improve application performance.
  7. Strategies for creating custom UI widgets in GWT

    main

    GWT provides three primary strategies for creating custom user interface elements:

    1. Building Composites: Extend the Composite class to combine existing widgets into a single reusable component. This is the most effective and recommended method.
    2. Creating from Scratch: Write a new widget from the ground up using Java code. This involves working at a lower level (similar to how Button or TextBox are implemented).
    3. Wrapping JavaScript: Use JSNI methods to wrap existing JavaScript functionality. This should be a last resort due to cross-browser implications and debugging difficulty.
  8. Access GWT learning materials and community forums

    main

    The GWT documentation site provides several curated resources for developers to learn the framework and engage with the community:

    Learning Resources

    • GWT Presentations: Browse slides and videos from GWT presentations.
    • Articles and Tutorials: Access a collection of articles, tutorials, and blog posts discussing GWT.
    • Books: Find books focused exclusively on GWT development.

    Community Channels

    • GWT Developer Forum: A Google Groups forum for general discussions among developers building web apps with GWT. The engineering team is active here.
    • GWT Open Source Contributor Forum: A Google Groups forum specifically for engineering conversations related to improving GWT.
    • IRC Channel: An unofficial IRC channel ##gwt is available on Freenode.
  9. Choose an internationalization technique in GWT

    main

    GWT provides several ways to internationalize your application depending on your requirements:

    • UiBinder I18n: Use this if you are using UiBinder for your UI.
    • Static String Internationalization: The most efficient and type-safe method. It uses strongly-typed Java interfaces (Constants, ConstantsWithLookup, or Messages) and properties files to provide locale-aware messages resolved at compile time.
    • Dynamic String Internationalization: Use the Dictionary class for a flexible approach that looks up localized values defined in a module's host page without requiring recompilation.
    • Non-String Localized Values: Use Constants or ConstantsWithLookup to store primitives, String arrays, or String maps.
    • Parameterized Messages: Use the Messages interface if you need to substitute parameters into translated strings.
    • Interoperability: Use Dictionary to integrate GWT functionality into existing web applications that already have their own localization process.
  10. Supported HTML5 features in GWT

    main

    GWT provides support for several key HTML5 features. Use the following modules and APIs to implement these capabilities in your application:

    • Client-side Storage: Use LocalStorage, SessionStorage, and monitor StorageEvents for persisting data in the browser.
    • Canvas: Use the Canvas API for adding visualizations and complex graphics.
    • Audio: Use the Audio widgets for playing sound files.
    • Video: Use the Video widgets for playing video content.
  11. Understand GWT Licensing and Terms of Service

    main

    The GWT website and its operation are subject to the Google Terms of Service.

    Regarding the software itself:

    • GWT Software and Sample Code: Licensed under the Apache License, Version 2.0.
    • Third-Party Software: Other software included in the distribution is provided under different licenses, which are listed in the 'Included Software and Licenses' section of the official documentation.
    • Updates: The executable version of GWT distributed by Google may communicate with Google's servers to check for and prompt the installation of available updates.