Generics and IDs

August 25th, 2008 Graham Sanderson

Historically in our Teamworks product, identifiers for all objects persisted in the database were BigDecimal. Since there was no type information associated with the BigDecimal, it was possible to introduce bugs where the ID of an object of type A was passed to a method expecting the ID of an object of type B. Depending on the situation, this could cause an exception, or silent incorrect behavior.

When we came to write Blueprint, we had a clean slate, and wanted to do better. In addition we had the (at the time) luxury of using JDK5.0.

IDs in Blueprint, are 64 bit DB-local values. No two entities have the same ID even if they are of different types (this isn’t necessary, but provides added safety and security)

For Blueprint, our main goal was compile time type safety. It should be a compiler error to pass the wrong type of ID to a function. Other than that we wanted IDs to be as small as possible, and we had no requirement for run time introspection of types (by specifying type information everywhere in the source we can guarantee that compile time type safety translates to run type type safety)
Read the rest of this entry »

Posted in Java | No Comments »

GWT Generator Experiments

August 10th, 2008 Alex Moffat

In the Google Web Toolkit Generators form part of the Deferred Binding mechanism. They are one way of producing different code for different browsers or locales. When you write

Type myObj = GWT.create(Type.class)

a Generator is invoked at GWT compile time, before the conversion from Java to JavaScript, to produce the concrete Java code that implements Type. Ray Cromwell from Timepedia has written a three part series (one, two, three) showing how to write a Generator. I think I also have a use for the Generator mechanism, here’s my take on how to write one.
Read the rest of this entry »

Posted in GWT, Uncategorized | 1 Comment »

Using the GWT SuggestBox with RPC - Part Three

July 27th, 2008 Alex Moffat

Following on from Part One and Part Two this final post describes a SuggestOracle implementation that returns suggestions from a servlet. All of the code examples are available for download. There are three guidelines to the design of the RPC based SuggestOracle.

First, avoid the problem I described in Part One where an optimization in the SuggestBox to deal with an empty query string coupled with slower responses from the SuggestOracle can lead to the suggestion drop down appearing when the SuggestBox itself is empty. This is prevented by checking the length of the query string and returning an empty list for single character queries.

Second, use only one connection to the server. As shown in Part Two IE6 and IE limit you to two open connections to the server at once. This design uses a single connection leaving one free if needed.

Third, limit the number of times the server is called by using, if possible, results from an earlier request to the server to satisfy a later one.
Read the rest of this entry »

Posted in EffectiveGWT, GWT | No Comments »

Using the GWT SuggestBox with RPC - Part Two

July 22nd, 2008 Alex Moffat

When we use RPC to retrieve suggestions it’s best if we limit the number of requests we make. This is to avoid overloading the server and because of the two connection limit that some browsers have. This restricts you to two open connections from the browser to each different server. I’m going to show what this looks like in terms of the pattern of requests made to the server and how this impacts the RPC SuggestOracle.
Read the rest of this entry »

Posted in EffectiveGWT, GWT | No Comments »

TinyMCE Rich Text Editor with GWT

July 16th, 2008 Austin Arnold

In order for Blueprint to be a useful tool at capturing documentation, it needed to have a better rich text editing experience. In this post I will describe how to integrate the TinyMCE rich text editor into a GWT application, mainly focusing on the user-interface aspect. I will provide examples in which you can utilize methods from the TinyMCE API, as well as ways you can add your own functionality to the editor.
Read the rest of this entry »

Posted in GWT | 2 Comments »

Using the GWT SuggestBox with RPC - Part One

July 13th, 2008 Alex Moffat

Continuing from my previous post on SuggestBox styling this post is the first part of a look at how to create a GWT SuggestBox that gets its suggestions from a server using RPC. A SuggestBox is a good GUI component to choose when the user is likely to know the prefix for the string they want to enter and that string is likely a member of an existing set of possible string. It’s to save the user from having to type the whole string, not a substitute for a search facility. For example, entering an email address is a good candidate because the user knows the prefix, which is very likely to uniquely identify the address the user is searching, the SuggestBox can save them the effort of typing the domain name, and the previous emails addresses the user has used form a good set to extract suggestions from.
Read the rest of this entry »

Posted in EffectiveGWT, GWT | No Comments »

CSS styles for a GWT SuggestBox

July 6th, 2008 Alex Moffat

I’ve wanted for a while to experiment a bit with the GWT SuggestBox widget. I’m most interested in the performance of a SuggestBox that gets suggestions from the server and how best to structure the code for one. Once I got started though I realized that the first problem I had to solve was how to get a reasonable looking SuggestBox for the examples. In this post I describe the HTML structures created by a SuggestBox and how to use CSS to style them. The next post will talk about how to use SuggestionOracle etc.
Read the rest of this entry »

Posted in EffectiveGWT, GWT | No Comments »

Writing a GWT Linker

June 29th, 2008 Alex Moffat

In GWT 1.5 the build process is internally divided into two phases, compilation, which creates JavaScript from Java, and linking, which takes the JavaScript and other resources produced by the compilation phase and packages it for deployment. I wanted to understand a bit more about the linking process after seeing Bob Vawter talk about Resource Bundles and Linkers in GWT at the Google I/O conference. To try and help me do that I’ve created a linker that you can include in you build process to create a sort of manifest file listing which generated JavaScript file applies to which permutation of browser, locale etc.
Read the rest of this entry »

Posted in GWT | 3 Comments »

Overlay types, the dom and deferred binding in GWT 1.5

June 22nd, 2008 Alex Moffat

This post looks at the JavaScript that gets generated when using the new DOM classes introduced in GWT 1.5. It’s interesting to see how how overlay types, inlining and deferred binding work together to give you JavaScript that is faster and more compact than anything you would generally write by hand. I’ve included all of the code for the example at the end of the post.
Read the rest of this entry »

Posted in GWT | No Comments »

Animation with GWT

June 14th, 2008 Alex Moffat

After our Google IO presentation this year Using GWT to build a high performance collaborative diagramming tool someone came up to me and asked how the animation that Blueprint provides when you add milestones to the map is implemented. The little movie below shows what the effect looks like.
Boxes come in from the left and move to their final position. Existing boxes shrink if needed to provide space for the new boxes. This post describes how it’s done and provides a simple demonstration implementation you can download.
Read the rest of this entry »

Posted in GWT | No Comments »