Close
Back

What’s new in GWT 2.7

GWT 2.7 was just released, 10 months after GWT 2.6, with the main focus on debugging and development speed through SuperDev mode and incremental compilation. GWT 2.7 has no doubt played a central role in Google’s latest Inbox for GMail release so let’s dive deeper into this new release.

SuperDev mode as default

The single largest feature in GWT 2.7 is SuperDev mode, with Dev mode now deprecated. You use the browser’s built in debugger and don’t need to use any browser plugins. With SuperDev mode, all of your debugging happens right inside your browser, making it easier to debug mixed Java/Javascript code. If you are familiar with Super Dev Mode in 2.6, you will also notice that you no longer need any bookmarklets to enable/recompile when using Super Dev Mode, the code is recompiled automatically when you reload the page.

For more information on SuperDev mode see gwtproject.org.

Incremental compilation

If you have a large GWT project, you will instantly notice the incremental compilation feature of GWT 2.7. No longer will Super Dev Mode recompile your full project but instead only recompile the changed parts. The speedup in development is significant.

Easier Javascript integration

The new annotation based JsInterop allows you to quickly and easily integrate your GWT classes with Javascript. Instead of writing JSNI methods/JSO classes, you can simply annotate (@JSType, @JSProperty) which Javascript should be mapped to your Java file.

An example of JSInterop was already given at GWT.create 2013 by Goktug and Daniel, by reducing the amount of code from

class Window extends JavaScriptObject {
  public native void alert(String msg)/-*{
    this.alert(msg);
  }-*/;
  public native boolean void confirm(String msg)/-*{
    this.confirm(msg);
  }-*/;
  public native boolean addEventListener(String event, EventListener listener)/-*{
    var callback = function(evt) {
	  listener.@com.google.gwt.user.client.EventListener::onBrowserEvent(*)(evt);
    };
    this.addEventListener(event, callback);
  }-*/;
}

to just this

@JsInteface
interface Window {
  void alert(String msg);
  boolean confirm(String msg);
  void addEventListener(String event, EventListener listener);
}

Do note that JsInterop is still experimental in GWT 2.7 and will likely change in the future. You will need to add an X flag to the compiler to enable it in GWT 2.7

New GSS resources

CssResource is using Flute to parse the CSS, but it only supports CSS2 and a couple of features added for Gwt. With GssResource, GWT comes to a new era, not only supporting modern CSS syntax but also the Closure Stylesheets semantics. Now it will be even easier to write CSS since the closure processor adds variables, functions, conditionals, mixins and much more to the standard CSS3.

@def PADDING_RIGHT 50px;
@def PADDING_LEFT 50px;

@defmixin size(WIDTH, HEIGHT) {
  width: WIDTH;
  height: HEIGHT;
}

.class-name {
    @mixin size(add(PADDING_RIGHT, 150px, PADDING_LEFT), 50px);
    padding-right: PADDING_RIGHT;
}

Both CssResources and GssResources will live together in 2.7.0 for backward compatibility, but the old one will be removed in a future release.

How can I start using GWT 2.7?

GWT 2.7 is available in Maven central and on http://www.gwtproject.org/download.html

What’s in it for Vaadin developers?

Vaadin is a part of the GWT Steering Committee, and heavily vested in GWT through the GWT.create conference. As a Vaadin developer, you’ll be able to leverage the latest enhancements in GWT 2.7 in your add-on development starting from Vaadin 7.4.

See the release notes for GWT 2.7.0

Comments
Trackback URL:

Add Comment
Posted on 11/21/14 5:26 AM.
I'm wondering how Vaadin's SASS compares to the new GSS. Are there any advantages to using one over the other? If they're essentially the same, will Vaadin eventually move to using GSS instead (e.g. for Valo)?
Posted on 11/26/14 9:16 PM.