TurboManage

David Chandler's Journal of Java Web and Mobile Development

  • David M. Chandler


    Web app developer since 1994 and Google Cloud Platform Instructor now residing in Colorado. Besides tech, I enjoy landscape photography and share my work at ColoradoPhoto.gallery.

  • Subscribe

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 225 other followers

  • Sleepless Nights…

    October 2009
    S M T W T F S
     123
    45678910
    11121314151617
    18192021222324
    25262728293031
  • Blog Stats

    • 1,015,442 hits

Archive for October 2nd, 2009

GWT easy i18n with GIN

Posted by David Chandler on October 2, 2009

Short version, from the GIN tutorial:

Note that if GIN can’t find a binding for a class, it falls back to calling GWT.create() on that class. What this means that image bundles and translated messages will just magically work.

Longer version
Suppose we have some GWT Constants we want to make available application-wide. We have our usual Constants interface

import com.google.gwt.i18n.client.Constants;

public interface MyConstants extends Constants {
	String copyright();
	String logoPath();
}

and the corresponding MyConstants.properties in the same package:

copyright=Copyright 2009 David M Chandler All Rights Reserved.
logoPath=/images/logo.jpg

Now suppose we don’t want to call GWT.create() on it in every class in order to save resources. Thanks to the GIN capability mentioned above, any class created with GIN (which is all views and presenters if you’re using gwt-presenter) can simply do this:

	@Inject
	private MyConstants constants;

There’s no need to create a binding for MyConstants in our GIN module for the above to work, but to get singleton behavior, which is the whole point of this exercise, we must bind it as such in our GIN Module:

bind(MyConstants.class).in(Singleton.class);

Now we’ve theoretically saved some memory and/or CPU by using a singleton, although I wouldn’t be surprised if GWT.create() already does this optimization for Constants and Images…

Posted in Google Web Toolkit | 3 Comments »

gwt-dispatch and com.google.gwt.user.client.rpc.SerializationException

Posted by David Chandler on October 2, 2009

I’d written a new gwt-dispatch ActionHandler with corresponding Action and Result classes and was getting the above exception. The cause turned out be very simple: Action and Result classes implement java.io.Serializable and GWT-RPC therefore requires that they have an empty constructor. So when you get the yellow squiggly in Eclipse that prompts you to generate a serial ID, add an empty constructor, too, and save yourself some grief.

Posted in Google Web Toolkit, Headsmack, Model-View-Presenter | Leave a Comment »

 
%d bloggers like this: