GWT using Activities and Places

I’ve tried to simplify and categorize my vision of “Activities and Places” in real application since HelloWorld app from Google’s page doesn’t provide overview of the full-cycle development and shows us only 10% of the iceberg. Maybe this diagram will help someone either. Although in most cases the whole page can be one active area, example shows how to use two independent displays on the page (in this case Menu and Content). It can be useful, for example if you have completely different page views for site-administrator and user.

GWT Designer for Eclipse Juno on Ubuntu 12.X

Today I’ve tried to install Google Eclipse Plugin to draw some forms for my GWT-based app and caught the exception:

GWT http-server started at 127.0.0.1:45658
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fb2229d45a0, pid=8150, tid=140404439688960
#
# JRE version: 6.0_37-b06
# Java VM: Java HotSpot(TM) 64-Bit Server VM (20.12-b01 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libwebkitgtk-1.0.so.0+0x14245a0]  void WTF::freeOwnedGPtr<_GdkEvent>(_GdkEvent*)+0x15df0
#
# An error report file with more information is saved as:
# /home/ipcreeper/hs_err_pid8150.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Searching for at least an hour I’ve finally found the solution:

 

Step 1:

Download and install libhunspell package (xulrunner has a dependency on it):

http://packages.ubuntu.com/oneiric/amd64/libhunspell-1.2-0/download

sudo dpkg -i libhunspell-1.2-0_1.2.14-4_amd64.deb

Step 2:

Download and install xulrunner package:

http://packages.ubuntu.com/lucid/amd64/xulrunner-1.9.2/download

sudo dpkg -i xulrunner-1.9.2_1.9.2.28+build1+nobinonly-0ubuntu0.11.04.1_amd64.deb

Be aware that both libhunspell and xulrunner should be either i386 or amd64 version.

Step 3:

Open eclipse.ini and add path to installed xulrunner:
-Dorg.eclipse.swt.browser.XULRunnerPath=/usr/lib/xulrunner-1.9.2.28

Step 4:

If editor still not running, try to set the environment variable GDK_NATIVE_WINDOWS to false before starting Eclipse. Do it with following command:

export GDK_NATIVE_WINDOWS=false

GWT: client code optimization

I’d like to share with you one tip which I’ve learned only yesterday, in spite of the fact that you may already know it.

Our GWT project is written with a lot of modules that include initialization of child modules in their constructors which initialize a lot of another modules in their constructors and so on… Some modules can load different data for initial rendering, despite the fact that user won’t see them in current session, however this data and asynchronous calls are forcing application server to do unuseful job and weighty client code makes some delays on application start up in user’s browser.

Here is the solution! Recently I read about ReadAsyncCallback interface which allows to easily make deferred calls right in the client code. Just imagine, it allows you to make deferred method call in a client code in the same way as you make requests to your remote services:

GWT.runAsync(new RunAsyncCallback() {
    public void onSuccess() {
      new SomeModule().show();
    }
    public void onFailure(Throwable ohNoes) {
    }
  });

This really simple method tells compiler to split your code into parts if it possible without any bad consequences.

To learn some details and limitations of this feature read the official documentation.