Activate your free membership today | Log-in

Friday, October 3rd, 2008

Vista / OS X Mash-up Created with GWT on PHP

Category: GWT, PHP, Showcase

Here’s an interesting link for a Friday. Viktor Zeman on Quality Unit sent us a link to “PostAffiliateXpress“, some boring IT application with an interesting interface and an even more intriguing back-end.

The UI combines a Vista-like “Start” menu along with an OS X-like dock (using everyone’s favorite fish-eye widget). It also has a built-in widget system that leverages Google Widgets. Overall, it’s a pretty nice implementation of a desktop and windowing in Ajax.

The framework itself is “GwtPHP” which attempts to take all the advantages of GWT and deploy them to PHP backends in an attempt to solve the problem of limited Java-friendly hosting services. Unfortunately, the framework isn’t available for use until sometime in early November.

Dual-License

The developers intend to use the familiar “free for hobbyists, pay up for commercial use” licensing model (what their licensing page calls a “what for what” model).

Give some feedback

Viktor says that they are quite keen to get feedback from folks on the project, so interested folks should get in touch, let them know what you think about the licensing model, and perhaps get early access, etc.

Posted by Ben Galbraith at 10:51 am
7 Comments

+++--
3.3 rating from 37 votes

Thursday, September 18th, 2008

Ext GWT 1.1 Released

Category: Ext, GWT

Darrell Meyer has announced the release of Ext GWT 1.1 which is said to “shortens the feature set gap between Ext JS.”

New Features

The Grid component wraps the Ext JS grid, and it includes support for grid plugins which fit into component lifecycles. You can also use a subclass, EditableGrid which…. allows you to edit content on the fly.

Auto complete has been added to the combo boxes a la Google Suggest.

Portal is a custom layout container that uses a multi-column layout on contains Portlets. Each Porlet can be drag and dropped to change order or move to another column. Each Portlet can contain any content and supports icons to expand / collapse, close, etc.

The desktop mimics the behavior of the operating system look at feel. It is now possible to create multi-window applications with support for a task bar and start menu. Windows support normal, maximize, and minimize states. The start menu is a custom menu that allows new menu items. In addition, there is support for a “task” area for adding additional items.

Java Bean Support with BeanModel

The Ext GWT Store and Binder API work with ModelData instances. The primary goal of ModelData is to provide a type of “introspection” as GWT does not allow runtime inspection of Java objects. You can query ModelData for a list of properties it contains, and these properties can be retrieved and set using the parameter name with the get and set methods.

Although this approach works, it forces you to either implement the ModelData interface in your Java Beans or extend the Ext GWT base classes that implement the ModelData interface. What is missing is a way to use your Java Beans as is, without having to extend the Ext GWT base classes or implement an “invasive” interface.

There are also new examples:

  • Forum search is an example of a combo box, using a custom XTemplate, and remote data. The data can be paged with built-in support for a paging toolbar.
  • Image Chooser shows loading a ListView in a Window. Each item has a linked details view, and the ListView supports custom sorting and filtering.
  • This example shows a Dialog using an AnchorLayout to “anchor” the form fields to the dialog dimensions. When resized, the fields will adjust their size to match the dimensions of the dialog.

Posted by Dion Almaer at 7:25 am
15 Comments

++++-
4 rating from 35 votes

Friday, August 29th, 2008

GWT 1.5 final release is shipped and out the door

Category: GWT, Google, Java, Library

I have seen the GWT team working very hard indeed on GWT 1.5, and they must be very happy to see the final release shipped and complete:

GWT 1.5 delivers what we think are an impressive number of improvements, about four hundred issues if you’re counting. We’re also happy that one of those is issue 168, our most-requested feature, Support for Java 5.

The high level new feature sets are:

  • Java 5 language support and enhanced JRE emulation
  • Performance optimizations and easier JavaScript interop
  • Prettier widgets, better DOM, accessibility, and bi-di

You can see a lot of this at work in the showcase area. There you will see all of the widgets and examples that come out of the box, and the community has developed even more for you. In particular, Ray Cromwell has some great real world examples that he shares in his book and talk.

Download GWT and take a look.

Posted by Dion Almaer at 10:51 am
1 Comment

++++-
4 rating from 24 votes

Thursday, August 28th, 2008

GALGWT 1.0… it isn’t a land next to Mordor

Category: GWT, Gears, Google

GWT has long had a project that aimed to give rich support for Google APIs called GALGWT, or “Google API Libraries for Google Web Toolkit”.

This project has stepped up to higher gear recently, and we have seen the GALGWT 1.0 release candidate appear.

What is in GALGWT?

The project is a collection of libraries that provide Java language bindings
and API specific ‘plumbing’ for some Google JavaScript APIs. The goal is to
make it easy for developers to use these JavaScript APIs with GWT. Libraries
available at this time include a new version of Gears, as well as new
libraries for Gadgets and the Google AJAX Search API.

Gears 1.1 Library

A new version of the Gears library is available. In addition to the earlier
version’s support for the Gears LocalServer, Database, and WorkerPool, 1.1
adds integrated support for offline applications and updated sample
applications. The bindings have also been refactored to use GWT 1.5
JavaScript overlay types and a new package hierarchy.

Gadgets 1.0 Library

The Gadgets library simplifies gadget development with GWT by automatically
generating a Gadget specification from Java source and inserting a selection
script in the specification much like a regular GWT project. After compiling
your gadget with GWT, all files are in place to publish your gadget. This
version currently supports the legacy Gadgets API based on the _IG_…
namespace.

Google AJAX Search 1.0 Library

The Google AJAX Search API lets you put Google Search in your web pages,
including Web, Local, and Multimedia searches. This library allows you to
access the API from Java code compiled with the GWT compiler without having
to write additional JavaScript code.

Posted by Dion Almaer at 5:45 am
Comment here

++++-
4 rating from 5 votes

Tuesday, August 19th, 2008

SmartGWT: LGPL GWT wrapper on SmartClient

Category: GWT

Sanjiv Jivan, original creator of GWT-Ext, posted on SmartGWT, a new wrapper on top of SmartClient.

Charles Kendrick of Isomorphic, creator of SmartClient, announced the new project as well as the approach they have taken:

we’ve taken an approach of generating GWT code from SmartClient’s documentation, combined with hand-coding portions that can’t feasibly be generated. By tweaking our documentation set to contain additional metadata (some of it GWT-specific), we’ve been able to generate code you might not otherwise expect, including things like enumerated constants and convenience constructors.

What this means is that the first release of SmartGWT will provide the complete SmartClient API, fully documented.

You can now write code such as:

JAVASCRIPT:
  1.  
  2. import org.smartgwt;
  3. import org.smartgwt.client.widgets.Button;
  4.  
  5. ...
  6.  
  7. Button button = new Button("myButton", "Click me");
  8. button.addClickListener(new ClickListener() {
  9.     public void onClick(ClickEvent event) {
  10.         ISC.say("Hello World!");
  11.     }
  12. });
  13.  

Sanjiv Jivan joined the project under the terms that Isomorphic sign a document that said:

The founders of Isomorphic Software are committed to keeping a complete, up-to-date version of SmartClient available under an LGPL license.

We continue to invest heavily in building new features, skins, tutorials, and tools for SmartClient LGPL.

We think it's normal and expected that some people receive great benefit from LGPL software and do not pay. The spirit of open source, in a nutshell, is that releasing free software creates so much wealth that the portion that flows back to you is more than enough.

Sincerely,
Charles Kendrick
Alex Shvedoff

Posted by Dion Almaer at 8:36 am
2 Comments

++++-
4 rating from 25 votes

Tuesday, August 5th, 2008

JavaScript Overlay Types in GWT

Category: GWT

Bruce Johnson of the GWT team has continued the deep dive into GWT with a posting on a new GWT 1.5 feature: JavaScript overlay types. This feature goes beyond the JNSI technique to "make it easy to integrate entire families of JavaScript objects into your GWT project. There are many benefits of this technique, including the ability to use your Java IDE's code completion and refactoring capabilities even as you're working with untyped JavaScript objects."

The first example that Bruce gives is to mix JSON objects with Java:

JAVASCRIPT:
  1.  
  2. var jsonData = [
  3.   { "FirstName" : "Jimmy", "LastName" : "Webber" },
  4.   { "FirstName" : "Alan""LastName" : "Dayal" },
  5.   { "FirstName" : "Keanu", "LastName" : "Spoon" },
  6.   { "FirstName" : "Emily", "LastName" : "Rudnick" }
  7. ];
  8.  
JAVA:
  1.  
  2. // An overlay type
  3. class Customer extends JavaScriptObject {
  4.  
  5.   // Overlay types always have protected, zero-arg ctors
  6.   protected Customer() { }
  7.    
  8.   // Typically, methods on overlay types are JSNI
  9.   public final native String getFirstName() /*-{ return this.FirstName; }-*/;
  10.   public final native String getLastName()  /*-{ return this.LastName;  }-*/;
  11.    
  12.   // Note, though, that methods aren't required to be JSNI
  13.   public final String getFullName() {
  14.     return getFirstName() + " " + getLastName();
  15.   }
  16. }
  17.  
JAVA:
  1.  
  2. // the glue
  3.  
  4. class MyModuleEntryPoint implements EntryPoint {
  5.   public void onModuleLoad() {
  6.     Customer c = getFirstCustomer();
  7.     // Yay! Now I have a JS object that appears to be a Customer
  8.     Window.alert("Hello, " + c.getFirstName());
  9.   }
  10.  
  11.   // Use JSNI to grab the JSON object we care about
  12.   // The JSON object gets its Java type implicitly based on the method's return type
  13.   private native Customer getFirstCustomer() {
  14.     // Get a reference to the first customer in the JSON array from earlier
  15.     return $wnd.jsonData[0];
  16.   }
  17. }
  18.  

Bruce then shows us some performance wins that you get, as GWT gets to do a lot of inlining:

A quick digression for compiler geeks. Another neat thing about overlay types is that you can augment the Java type without disturbing the underlying JavaScript object. In the example above, notice that we added the getFullName() method. It's purely Java code — it doesn't exist on the underlying JavaScript object — and yet the method is written in terms of the underlying JavaScript object. In other words, the Java view of the JavaScript object can be richer in functionality than the JavaScript view of the same object but without having to modify the underlying JS object, neither the instance nor its prototype.

(This is still part of the digression.) This cool wackiness of adding new methods to overlay types is possible because the rules for overlay types by design disallow polymorphic calls; all methods must be final and/or private. Consequently, every method on an overlay type is statically resolvable by the compiler, so there is never a need for dynamic dispatch at runtime. That's why we don't have to muck about with an object's function pointers; the compiler can generate a direct call to the method as if it were a global function, external to the object itself. It's easy to see that a direct function call is faster than an indirect one. Better still, since calls to methods on overlay types can be statically resolved, they are all candidates for automatic inlining, which is a Very Good Thing when you're fighting for performance in a scripting language.

From this Java code:

JAVA:
  1.  
  2. class MyModuleEntryPoint implements EntryPoint {
  3.   public void onModuleLoad() {
  4.     JsArray<customer> cs = getCustomers();
  5.     for (int i = 0, n = cs.length(); i <n; ++i) {
  6.       Window.alert("Hello, " + cs.get(i).getFullName());
  7.     }
  8.   }
  9.  
  10.   // Return the whole JSON array, as is
  11.   private final native JsArray<Customer> getCustomers() /*-{
  12.     return $wnd.jsonData;
  13.   }-*/;
  14. }
  15.  

The compiler inlines away to get to the followinig (not obfuscated to see):

JAVASCRIPT:
  1.  
  2. function $onModuleLoad(){
  3.   var cs, i, n;
  4.   cs = $wnd.jsonData;
  5.   for (i = 0, n = cs.length; i <n; ++i) {
  6.     $wnd.alert('Hello, ' + (cs[i].FirstName + ' ' + cs[i].LastName));
  7.   }
  8. }
  9.  

Posted by Dion Almaer at 8:10 am
Comment here

+++--
3.3 rating from 13 votes

Friday, August 1st, 2008

chosr: Quicksilver interface in the Web

Category: GWT, Showcase

Chosr is another Quicksilver inspired piece of software, that lives in the Web, created by Julius Eckert using GWT.

Very interesting to see the interactions, although I wonder a little on the usage. The great thing about Quicksilver is that you hit a quick key combo and you are there. You type what you need, and you are sent off again.

Posted by Dion Almaer at 2:10 am
4 Comments

++---
2.7 rating from 21 votes

Wednesday, July 23rd, 2008

Getting to know GWT JSNI; Including talking to GWT code from JavaScript

Category: GWT, JavaScript

Bruce Johnson has written an expansive post on understanding the GWT JavaScript Native Interface (JSNI). It starts out with the piece that some people know about, namely inlining native JavaScript such as this:

JAVA:
  1.  
  2. // Java method declaration...
  3. native String flipName(String name) /*-{
  4.   // ...implemented with JavaScript
  5.   var re = /(\w+)\s(\w+)/;
  6.   return name.replace(re, '$2, $1');
  7. }-*/;
  8.  

But what about calling back out to Java from within native land?

JAVA:
  1.  
  2. package org.example.foo;
  3. public class Flipper {
  4.   public native void flipName(String name) /*-{
  5.     var re = /(\w+)\s(\w+)/;
  6.     var s = name.replace(re, '$2, $1');
  7.     this.@org.example.foo.Flipper::onFlip(Ljava/lang/String;)(s);
  8.   }-*/;
  9.  
  10.   private void onFlip(String flippedName) {
  11.     // do something useful with the flipped name
  12.   }
  13. }
  14.  

You can also access any JavaScript, loaded from a script source or however via:

JAVA:
  1.  
  2. // A Java method using JSNI
  3. native void sayHelloInJava(String name) /*-{
  4.   $wnd.sayHello(name); // $wnd is a JSNI synonym for 'window'
  5. }-*/;
  6.  

But finally, what about if you wrote a bunch of Java code for GWT, and you want JavaScript to call that? Simply link the code back through the $wnd world:

JAVA:
  1.  
  2. package org.example.yourcode.format.client;
  3. public class DateFormatterLib implements EntryPoint {
  4.  
  5.   // Expose the following method into JavaScript.
  6.   private static String formatAsCurrency(double x) {
  7.     return NumberFormat.getCurrencyFormat().format(x);
  8.   }
  9.  
  10.   // Set up the JS-callable signature as a global JS function.
  11.   private native void publish() /*-{
  12.     $wnd.formatAsCurrency =
  13.       @org.example.yourcode.format.client.DateFormatterLib::formatAsCurrency(D);
  14.   }-*/;
  15.  
  16.   // Auto-publish the method into JS when the GWT module loads.
  17.   public void onModuleLoad() {
  18.     publish();
  19.   }
  20. }
  21.  

For more, check out this talk on the topic given by the GWT architect Scott Blum:

Posted by Dion Almaer at 6:43 am
Comment here

+++--
3.8 rating from 11 votes

Tuesday, July 8th, 2008

Ext GWT 1.0: GWT 1.5 support, new APIs, performance, and docs

Category: Ext, GWT

Darrell Meyer has announced Ext GWT 1.0. This is the first fully stable release of the product and it includes a lot of goodies including:

  • Documentation: new screencasts of the various steps
  • GWT 1.5 support: "Ext GWT is a 100% native GWT application written in Java. Ext GWT does not wrap any 3rd party JavaScript and does not use any external JavaScript files. Ext GWT fully leverages the GWT API including the widget lifecylce, events, listeners, messaging, and RPC."
  • "Performance was a high priority item for the Ext GWT 1.0 release. Many changes were made since the first beta releases. Initial rendering times are quicker and the new layout code reacts quicker to window resizing. Improvements can easily be seen in the Explorer demo."
  • Advanced Form Layouts
  • Improved Data Loading, Store, Binder, and Field API

Looks like a very solid release indeed. Congrats to the team.

Posted by Dion Almaer at 8:15 am
4 Comments

++++-
4.2 rating from 61 votes

Monday, July 7th, 2008

Exploring GWT Linkers

Category: GWT

Alex Moffat has written up an exploration of GWT linkers. It looks at the linking part of the GWT compilation step using as an example a linker that creates a sort of manifest for the JavaScript files created by compilation so that you can easily tell which file goes with which browser/locale/etc. combination.

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.

To create a linker and have it called during the build process you need to do four things

  • Create a class that implements com.google.gwt.core.ext.Linker
  • Add a LinkerOrder annotation to the class to define whether the linker should run before the primary linker, after the primary linker or instead of the primary linker. You’re allowed as many linkers before and after the primary as you like but only one primary linker.
  • Define and add the linker in a <module>.gwt.xml file.
  • Include the new class in the classpath when running the gwt compiler.

The 1.5 RC1 build provides three different primary linkers that produce three different ways of packaging the compiler output for loading by the browser. The standard linker produces the familiar <module>.nocache.js file that loads the correct <strong name>.cache.html for the target browser. This is the linker that is added in Core.gwt.xml and so is the default linker that is used. Also provided are a cross site linker that creates a <module>-xs.nocache.js and a single script linker. You use the cross site linker if you need to host the GWT generated artifacts on a separate domain from your main site, for example if you use www.mysite.com for serving dynamic content and put all the static stuff, including JavaScript, on static.mysite.com. The single script linker can be used when the compilation process always creates a single JavaScript file that is applicable to all permutations.

Posted by Dion Alm