Question

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?

Was it helpful?

Solution

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

UPDATE: for latest in MVP design for GWT look for GWT MVP in GWT 2.1 and/or gwt-platform frameworks (among others that may work for you).

OTHER TIPS

UiBinder (GWT 2.0) could be helpful

Geez might help you.

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

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.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top