GWT: Google Web Toolkit

From Elvanör's Technical Wiki
Jump to navigation Jump to search

This page collects various information about GWT programming.

Java exceptions in the server side code

They need to implement IsSerializable. You must thus specify on your server code that the function throws SerializableException and not just Exception.

public interface ShopServices extends RemoteService
{
	/**
	 * 
	 * @gwt.typeArgs <com.example.client.ShopCategory>
	 */	
	
	public Set getShopCategories() throws SerializableException;
}

GWT automatic serialization

  • Be careful that GWT automatic serialization, especially for collections, can be tricky. You must specify in your Java source code what your collections contain. Maybe with Java 1.5 the situation will improve.
  • Besides, if you use Hibernate, Hibernate will fill your beans (objects) with its own implementations for collections (eg it will not use the implementations from java.util, but for a set will use org.hibernate.PersistentSet). Currently (as of GWT 1.3) there are several solutions available.
    • Do a mapping between the Hibernate beans and the GWT client beans (apparently this can be somewhat automated by using Dozer).