GWT: Google Web Toolkit: Difference between revisions

From Elvanör's Technical Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
This page collects various information about GWT programming.
This page collects various information about GWT programming.
== GWT configuration files: the GWT XML modules ==
Configuration files in GWT are called modules. In a module, you may specify (among other things):
* an entry point class (this class will be instantiated when the module will be read from the base HTML file and the gwt.js script);
* some source path (this will be translated to JavaScript by the GWT compiler);
* a public path (files on this directory will be copied to the deployment server);
* some CSS or native JavaScript files to be injected into the GWT code.
You can also inherit other GWT modules from one module. This is equivalent to copy all the contents of the inherited module into the current module.
'''Warning:''' be careful when inheriting modules. If the inherited module has a entry point class defined, it *will* get instantiated, even if your own module already has one. This can lead to confusion. If you just want to use the source from another package structure, use the <tt><source></tt> element.


== Java exceptions in the server side code ==
== Java exceptions in the server side code ==

Revision as of 12:43, 29 March 2007

This page collects various information about GWT programming.

GWT configuration files: the GWT XML modules

Configuration files in GWT are called modules. In a module, you may specify (among other things):

  • an entry point class (this class will be instantiated when the module will be read from the base HTML file and the gwt.js script);
  • some source path (this will be translated to JavaScript by the GWT compiler);
  • a public path (files on this directory will be copied to the deployment server);
  • some CSS or native JavaScript files to be injected into the GWT code.

You can also inherit other GWT modules from one module. This is equivalent to copy all the contents of the inherited module into the current module.

Warning: be careful when inheriting modules. If the inherited module has a entry point class defined, it *will* get instantiated, even if your own module already has one. This can lead to confusion. If you just want to use the source from another package structure, use the <source> element.

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).

GWT Client Widgets

  • StackPanel: If you apply a style (CSS) to this panel, it will actually be applied to the "panel in itself", NOT to the header (title) of the panel. If you wish to apply a CSS style to the header, enter the header directly as HTML code.

GWT Tools

Since you cannot really see the HTML source before it is created via the JavaScript, the Firefox add-on Firebug is really, really helpful with GWT.