Technical Articles by Sony Mathew, Software Architect, Twin Cities, MN

Tuesday, February 17, 2009

Issues with GWT

Google Web Toolkit (GWT) is an AJAX based RIA framework that promises to enrich your Java/JEE Web Applications with a Rich user experience. It also promises to ease error-prone JavaScript & HTML development by abstracting it under the safety of a compile-time language like Java. GWT is a good framework overall and delivers on most of its promises -but- a few short-comings are to be noted.

Reviewer: Sony Mathew, GWT version 1.5

  1. Great Tool support but...

    1. Being in Java all Java IDE tool support is available at your fingertips.
    2. Comes with a GWT Browser for immediate edit feedback but can be slow.
    3. Debugging of client-side and server-side seamless in Eclipse.
    4. Had to custom build: Eclipse plugin for compilation & workspace Ant tasks.
      • May not need as better plugins come out.
  2. UI Design in Java maybe cumbersome.

    1. No Graphical designer (GWT Designer exists, haven't tried, its for pay & don't expect much).
    2. Fix: Complex layouts can be easily abstracted into components and reused.
    3. Fix: Complex HTML layouts and semi-static HTML snippets can be easily abstracted to Static-Content and reassembled dynamically.
    4. Fix: Fluent interfaces like AxisPanel can be easily created to alleviate complex layouts
    5. Fix: Can purchase/obtain 3rd party rich components.
  3. Compilation takes a while.

    1. Don’t need to compile very often during dev.
    2. Compile initially and when making changes to RPC transported beans.
    3. View UI edits via GWT provided browser for changes.
  4. Browser inconsistencies abstracted well but...

    1. CSS inconsistencies still remain, All Widgets are CSS driven.
    2. HTML/JavaScript inconsistencies abstracted well but custom components will require some hand-coding of HTML & JavaScript.
  5. Cannot style all areas of all Widgets.

    • E.g. parts of TabPanel.
  6. Java/JRE Emulation limitations

    Requires that classes be scrubbed of following unsupported (non-compilable) references:
    1. 3rd Party classes:
      • e.g. org.apache.commons.*, org.hibernate.* etc.
      • Fix: Eliminate references.
      • Fix: Add source (.java) to classpath.
      • Fix: Use your own custom equivalents (e.g. custom ToStringBuilder).
    2. BigDecimal:
      • Client-side BigDecimal math not supported because it is not performant.
      • Fix: Can use 3rd party 'gwt-math.jar'.
      • Fix: Redesign beans to use Money, inject appropriate client/server side MoneyCalc.
    3. List.subList():
      • Fix: Use an explicit for-loop to create a new list.
    4. Object.clone():
      • Fix: Use a Copy Constructor and set fields individually.
    5. java.util.Calendar, java.text.DateFormat (and subclasses) :
      • Fix: Use deprecated java.util.Date constructors and methods.
      • Fix: Redesign beans to use java.util.Date, inject appropriate client/server side Formatters.
    6. java.text.NumberFormat and java.text.*:
      • Fix: Use GWT provided classes - not optimal unless on client side.
      • Fix: Redesign beans, inject appropriate client/server side Formatters.
    7. Misc RPC Serializing issues:
      • Doesn't serialize final fields.
      • HashMap: Make sure contents are serializable.
      • Old Style Enums require no-arg constructor and non-final fields.
    8. GWT Unit tests:
      • If present in same package can cause compile errors unless you scrub the tests: Including placing junit source on classpath.
      • Note: having different source folders will NOT help if .class files are compiled to same output location.
  7. Scrub Hibernate loaded beans of non-compilable references.

    1. Only if loaded beans reference Hibernate classes such as HashSet, Session etc.
    2. Only an issue for lazy-loaded associations & collections (verified).
      • Hibernate beans with no lazy assocs were readily serialized.
    3. Fix: Hibernate.initialize() on all objects
      • May not be sufficient - verify.
    4. Fix: Deep Copy beans:
      1. Manual Copy Constructors on beans.
      2. Use automated reflection based copy (including for collections).
  8. Can use server-side classes on client-side but...

    1. Requires a “gwt.xml” file in referenced Java package (2 lines).
    2. May require scrubbing of non-compilable references.
    3. May require scrubbing of Hibernate loaded beans for RPC serialization