GXT is open source

I have been working over the past few months with Sencha EXTJS4 javascript library. In my time with GWT, I have mainly used the Google widgets. However, I am pleasantly surprised that Sencha GXT also offers an open source version of their product.  Another popular offering for a widget library is SmartGWT.


May 27, 2012 at 6:45 pm Leave a comment

GWT Testing

I have done some mocking before, but for now the focus will be on the use of the  Mocking Framework known as Mockito














July 12, 2011 at 1:36 am Leave a comment

Getting to know the gwt xml file better

From the DevGuideOrganizingProjects : “the individual units of GWT configuration are called modules and are defined as XML files with a file extension of .gwt.xml”

From gwt style configuration reference guide:  “the source path is a relative path name used to override the default location of the client-side Java source destined to be compiled into JavaScript. The source path you specify is appended to the path where the module configuration file resides, and you may specify multiple source paths.”

Deferred Binding is a technique used by the GWT compiler to create and select a specific implementation of a class based on a set of parameters. For example, special  processing based on the user-agent  with ConditionalProperties .

More info can be found in the GWT Wiki: [DeferredBindings For JRE]

July 5, 2011 at 3:36 pm Leave a comment

MVP plus Activity/Places

I have been through the new GWT 2.1  HelloMVP example , but I was disappointed that for a new technique, it was just to simple of a scenario. I wanted a more involved use case to show the merits of the Activities / Places.  Luckily, I came across the Ashton Thomas GWT 2.1 seminar example and tutorial .

Starting off in the gwt.xml of this GWT 2.1 project:

<!-- Inherit GIN. -->
    <inherits name='com.google.gwt.inject.Inject'/>
<!-- Inherit Activity -->
    <inherits name='com.google.gwt.activity.Activity'/>
<!-- Inherit Place. -->
    <inherits name='com.google.gwt.place.Place'/>
<!-- Inherit Resources -->
    <inherits name='com.google.gwt.resources.Resources'/>

The class AcrintaSeminar is the entry point class.
DesktopInjector is a gin injector  interface that defines method  getAcrintaSeminarApp()  which returns  DesktopApp.
The class AppInjectorModule does the gin injecting:

  • event bus: SimpleEventBus
  • placeController: PlaceControllerProvider

Place: A place basically represents a certain state of your UI. The place is identified using a name. The place string you provide is bascially the history token that will trigger things such as a presenter to activate.

public abstract class AppPlace extends Place {
	public abstract String getToken();

PlaceController: In charge of the user’s location in the GUI.

public class PlaceControllerProvider implements Provider<PlaceController>{
	// set up the evenBus to be injected via the constructor
	private final EventBus eventBus;

Activity: is analogous to a presenter in MVP terminology. Activities are started and stopped by an ActivityManager associated with a container Widget.

public class HomeActivity extends AbstractActivity {
	private HomeView view;
	public void start(AcceptsOneWidget panel, EventBus eventBus) {


Activity Mapper: Returns the activity to run for the given place

public class MainActivityMapper implements ActivityMapper {…

	public MainActivityMapper(HomeActivity homeActivity, RsvpActivity rsvpActivity, AboutActivity aboutActivity,
								ContactActivity contactActivity, LocationActivity locationActivity, ResourcesActivity resourcesActivity){

	public Activity getActivity(Place place) {
		// there are other ways of doing this
		// but just check the instnaces and return
		// the appropriate Activity
		if(place instanceof HomePlace){
			return homeActivity;

ActivityManager: with a given place event, it associates a representative activity to invoke. Here you can start or stop activities where they are associated with a particular widget.

public class DesktopApp extends AcrintaSeminarApp {
	private final DesktopShell shell;
	private final EventBus eventBus;
	private final PlaceController placeController;
	private final MainActivityMapper mainActivityMapper;
	private final AppPlaceHistoryMapper appPlaceHistoryMapper;


	public void run(){
		/* Add handlers, setup activities */
		GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
			public void onUncaughtException(Throwable e) {
				Window.alert("Hey, something went wrong: " + e.getMessage());
				// we could log this if we were using logging...


		CachingActivityMapper cached = new CachingActivityMapper(mainActivityMapper);
		final ActivityManager mainActivityManager = new ActivityManager(cached, eventBus);


PlaceHistoryMapper: attach all places which the PlaceHistoryHandler should be aware of.

public class AppPlaceHistoryMapper implements PlaceHistoryMapper{

	private HomePlace homePlace;
	private RsvpPlace rsvpPlace;
	public Place getPlace(String token) {

			return homePlace;
		}else if(token.startsWith("rsvp")){
			return rsvpPlace;
		}else if(token.startsWith("about")){
			return aboutPlace;
		}else if(token.startsWith("contact")){
			return contactPlace;
		}else if (token.startsWith("location")){
			return locationPlace;
		}else if(token.startsWith("resources")){
			return resourcesPlace;

		return null;

	public Place getPlace(String token) {

			return homePlace;

PlaceHistoryHandler: updates the browser URL corresponding to each Place in your app.

public class DesktopApp extends AcrintaSeminarApp {
	private final DesktopShell shell;
	private final EventBus eventBus;
	private final PlaceController placeController;
	private final MainActivityMapper mainActivityMapper;
	private final AppPlaceHistoryMapper appPlaceHistoryMapper;


	public void run(){
// History management
		AppPlaceHistoryMapper historyMapper = appPlaceHistoryMapper;
		PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper);
		historyHandler.register(placeController, eventBus, defaultPlace);

		// add out UiBinder shell to the Root Panel (the main html document thingy)

July 4, 2011 at 8:38 pm Leave a comment

Easy To Use UI Binder in your GWT

UI Binder was introduced in GWT 2.0 . I had noted the new functionality in an earlier post.

#1 reason to use it: UiBinder can also make your app more efficient

public class SimpleEntryPoint implements EntryPoint {

  public void onModuleLoad() {

	  HelloWidgetWorld h = new HelloWidgetWorld();  


You must declare access to UiBinder. Here is HelloWidgetWorld.java:

 public class HelloWidgetWorld extends Composite{
        interface MyUiBinder extends UiBinder<
HTMLPanel, HelloWidgetWorld
> {}
	private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);

	ListBox listBox;

	public HelloWidgetWorld(){
		listBox.addItem("Willie Mays");


UiBinder<U, O> interface declares two parameter types:

  • HtmlPanel = U is the type of root element declared in the ui.xml file, returned by the createAndBindUi call
  • HelloWorld = O is the owner type whose @UiFields are to be filled in.


<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'

    Hello, <g:ListBox ui:field='listBox' visibleItemCount='1'/>.


July 3, 2011 at 3:25 pm Leave a comment

Developer Sharing June Edition

UI Binder  http://www.canoo.com/blog/2010/04/26/gwt-uibinder-better-web-app-separation-of-concerns/

UI Binder Dock Panel http://www.giantflyingsaucer.com/blog/?p=2302

UI Binder split panel http://www.giantflyingsaucer.com/blog/?p=2324

UI Binder Hello World http://blog.jeffdouglas.com/2010/01/19/gwt-uibinder-hello-world-tutorial/
Create a QR Code with Chart API  http://tamsler.blogspot.com/2010/08/how-to-create-qr-code.html

@Override in Java 6  http://www.bright-creations.com/blog/gwt-2-1-mvp-gin-example/

Strategy & Decorator patterns http://codeofdoom.com/wordpress/2009/05/10/learn-this-strategy-pattern-vs-decorator-pattern/

HTML5 canvas with gwt http://www.giantflyingsaucer.com/blog/?p=2350

GWT Module organizing http://www.summa-tech.com/blog/2011/02/22/structuring-gwt-modules-for-large-applications/

GWT new features http://tbroyer.posterous.com/gwt-211-requestfactory-part-ii http://tbroyer.posterous.com/gwt-21-editors http://tbroyer.posterous.com/gwt-21-places-activities-what-changed-between

GWT wraps JSON http://www.zackgrossbart.com/hackito/gwt-slider/

vaadin http://codebalance.blogspot.com/2011/06/developing-rich-web-interfaces-using.html

Advanced GWT Widgets   http://www.jhkuperus.nl/articles/java/gwt-dynamically-changing-css-styles/

June 29, 2011 at 12:30 am Leave a comment

Converting my GAE application from JDO to JPA

In past I had used the GAE with JDO, and in this exercise I will convert it to JPA.

In javasource/META-INF is the jdoconfig.xml:

<?xml version="1.0" encoding="utf-8"?>
<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
  <persistence-manager-factory name="transactions-optional">
    <property name="javax.jdo.PersistenceManagerFactoryClass" 
    <property name="javax.jdo.option.ConnectionURL" value="appengine"/>
    <property name="javax.jdo.option.NontransactionalRead" value="true"/>
    <property name="javax.jdo.option.NontransactionalWrite" value="true"/>
    <property name="javax.jdo.option.RetainValues" value="true"/>
    <property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>

private static final PersistenceManagerFactory PMF =

Example write:

PersistenceManager pm = getPersistenceManager();
try {
  pm.makePersistent(new Movie(getUser(), symbol, note));
} finally {

Example read and delete:

Query q = pm.newQuery(Movie.class, "user == u");
q.declareParameters("com.google.appengine.api.users.User u");
List<Movie> movies = (List<Movie>) q.execute(getUser());
for (Movie movie : movies) {
if (moviename.equals(movie.getSymbol())) {

Now to JPA queries:


private static final EntityManagerFactory EMF =
private EntityManager getEntityManager() {
	    return EMF.createEntityManager();
EntityManager em = getEntityManager();
		// Read the existing entries
		javax.persistence.Query q = em.createQuery("select m from Movie m");

public class Movie {

  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;

June 25, 2011 at 2:38 pm Leave a comment

Older Posts


Error: Twitter did not respond. Please wait a few minutes and refresh this page.