tags:

views:

654

answers:

5

I started learn GWT by example on google and my first conclusion is: too much code

Like this:

stocks.add(symbol);
     stocksFlexTable.setText(row, 0, symbol);
     stocksFlexTable.setWidget(row, 2, new Label());
     stocksFlexTable.getCellFormatter().addStyleName(row, 1,
       "watchListNumericColumn");
     stocksFlexTable.getCellFormatter().addStyleName(row, 2,
       "watchListNumericColumn");
     stocksFlexTable.getCellFormatter().addStyleName(row, 3,
       "watchListRemoveColumn");

Does GWT have any extensions for reducing code size and simplifying creating GWT forms?

+3  A: 

UiBinder (GWT 2.0) could be helpful

kaboom
+1  A: 

Geez might help you.

Geez provides easy to use style layouts for GWT and a series of static methods to build commonly used widgets.

Nat
+4  A: 

Nice example (oversimplified but clean conceptually) of GWT UI Design with CSS and HTML is Tags First GWT.

I agree with you that if one follows generic examples from Google documentation it's not a pleasant experience. The things changed lately though but they don't yet get fully reflected in the Google docs. Try the following: before going on with GWT development watch these 2 presentations: Best Practices and Performance Tips.

Without using CSS-based UI design, Event Bus, Command Pattern based GWT-RPC, MVP presentation tier and google-gin (GWT implementation of Guice) it's hard to overcome complexity in GWT just like in any other heavy GUI framework.

If you liked these ideas (described in the presentations above) you might want to consider gwt-dispatch and gwt-presenter that implement some of these patterns.

Few examples are: GWT MVP Example and Apache Labs Hupa GWT-based webmail

grigory
A: 

We use a FormBuilder class to easily and compactly construct forms in code:

ListBox type = ...
TextBox notes = ...

FormBuilder b = new FormBuilder();
b.label("Chart type").field(type).endRow();
b.label("Notes").field(notes).wrap().endRow();
b.add("Some help text").style("help").wrap().endRow();

FlexTable form = b.getForm();
...

It keeps track of the current row and column, styles cells consistently depending on the method used to add them (label, field etc.), ensures consistent spacing, etc etc. Each method returns a FormBuilder to support chaining calls. Things like wrap() apply to the previously added cell.

This class is part of the GWT Portlets framework.

David Tinker
A: 

Check out http://code.google.com/p/gwt-pectin/ in combination with UiBinder

Andrew