Showing posts with label GWT. Show all posts
Showing posts with label GWT. Show all posts

Charlottesville, VA beCamp 2011

Wow, what a great weekend at beCamp this year! I missed the setup and introductions because work kept me late Friday night, but I made it in time for proposing session topics (and pizza, of course). Running a session on Google Web Toolkit last year was a big thrill for me. I proposed GWT again, and ChromeOS, hoping to talk about my experiences with my Cr-48 since December. My GWT session got the same number of votes as last year, despite attendance being down something like 40% this year. Go me! ChromeOS didn't make the cut.

My first experience as a conference speaker was at beCamp 2010. In the spirit of the event, I proposed a session on GWT despite having no slides or other materials prepared. I got votes. I got scheduled. When I found myself in front of a dozen people with nothing prepared, I just started talking. I like GWT. I love using it. So, I went with that. What is GWT? Why do I use it? What do I love about it? That's what I talked about. And people asked questions. Lots of questions. I answered as many as I could as well as I could. People thanked me. This speaking thing wasn't so bad after all. I was even asked to give a presentation on GWT to the Richmond, VA Java User Group. I agreed. I obviously had a lot to say on the subject, and based on the response I was getting, people wanted to hear it. So I set about building slides for a presentation. I did my research. And in October 2010, I presented to about 25 people at the RJUG meeting. Nerves and a few technical issues aside, it went well. Now here I was, back at beCamp the following year, giving the presentation again. And people liked it. That feels good.

I gave the presentation using my Cr-48, only slightly disappointed that nobody wanted to hear about that too. But then after the session, I was approached. What was that notebook I used for the presentation? Oh, that's my Cr-48, a prototype Chromebook. I knew from the voting the night before that at least a couple of people were interested, so I was glad one of them had picked me out of the crowd later to talk about it. Then at lunch, more people gathered around interested in seeing it. Should I have put "Chromebook" on the topic card instead of "ChromeOS?" Are people more interested in the hardware than the operating system, or just more interested in seeing it in action? I'll propose the topic again next year, maybe under a different heading. I'll probably still be using the Cr-48 anyway, so if you're there and you want a look at it, come up and ask!

Thanks again to the organizer, Eric Pugh, all the sponsors, and everyone else who made beCamp 2011 possible. See you next year!

Richmond Java User Group - October

I gave a presentation on GWT at the Richmond JUG last night. There were about 20 people in attendance. Apart from some technical difficulties while demonstrating debugging in Development Mode, everything went well. We looked at the Google Plugin for Eclipse, some example GWT code created by the New Web Application wizard, and also briefly discussed Google App Engine.
I enjoyed having a chance to speak about a subject that is very exciting for me. I want to thank Remi Pelletier, Chris Allport, and the rest of the RJUG steering committee for organizing this and other RJUG events, and giving me a chance to speak. Thanks also to everyone who attended, listened, and asked questions.
I have granted access on Google Docs to a copy of the presentation I gave for anyone who wants to see it.

Richmond JUG

I drove into the city this evening for a meeting of the Richmond Java User Group. The topic was Sun Certified Enterprise Architect certification. It was a fine presentation with a lot of good points. The speaker was pro, of course, while I remain pretty firmly anti.

The speaker, Andy Pemberton, suggested that it's probably best to pursue certification for personal growth rather then any hope of financial benefit. The "value" of the certification is going to depend on where you work, and may not be worth anything in some organizations. But the knowledge acquired in obtaining the certification should be valuable anywhere. I think I can agree with that.

Andy said that the certification exam is a good motivation. It drives you to do the studying necessary to pass. I can agree with that too. But it also costs money. Not just books and the time to read them, but something like $900.00 to sit for the exam. That's a lot of money, at least to me. I can't justify spending that much money on the exam, especially when it isn't necessary to acquire the knowledge. You don't get feedback from the exam, just practice.

So what would I do for motivation? Open Source. If you want to learn something new and get a chance to practice it, why not join an Open Source project that uses the technology you want to learn? Or if one doesn't exist, start your own. The SCEA exam involves designing a software solution to a fictitious business problem. Why not find a real problem and write a real software solution, and then release it for free?

I have two Open Source projects that I started myself to explore ideas and write a little code: SimpleGWT and SimpleJDBC. As the names suggest, both are built on the theme of simple APIs for building real world software. I also participate in the Google Web Toolkit project as a community member and occasional code contributer. I think I get more out of these hobbies than I would out of a certification exam.

GWT, and AppEngine, and Eclipse - oh my!

There's much to be happy about for Java web developers this morning. Google has announced support for Java on AppEngine. Early access is being granted on a FIFO basis, however you can download the SDK now. But wait, there's more! This SDK includes the long-awaited Eclipse plugin for GWT! Read all about it on the GWT blog.

That's made my day.

GWT 1.6 Milestone 1 Announced

Scott Blum from the GWT team announced the release of GWT 1.6 Milestone 1 on the GWT Contributor's forum yesteday evening. 1.6 will include, among other things, many bug fixes, support for a new project structure that more closely resembles a standard WAR file, and a new event system that originated in the GWT Incubator.

Google I/O 2009

Google has announced Google I/O 2009, Developer Conference. I attended last year's event and I hope to go again this year. There will be sessions on App Engine, Android, Chrome, GWT, and other topics.

At I/O '08 I had the great pleasure of meeting members of the GWT team including Bruce Johnson, Sumit Chandel, and Miguel Mendez, as well as fellow GWT application developers. That was the first time I'd attended a developer conference and I found it completely worth the time and effort (I had to fly across the country to attend).

GWT in Eclipse

I came across this video last week. It's a presentation by Bruce Johnson, Technical Lead for the Google Web Toolkit on developing GWT applications with the Eclipse IDE. The first part of the presentation covers some basic introduction to GWT, followed by a little more detail on the inner workings of JSNI and hosted mode. The part I found most interesting was Bruce's discussion of the Eclipse plugin for GWT that Google has been working on internally but has not, as of yet, released to the general developer population. Some Q&A finishes out the session, as usual.

We've seen teasers about the plugin before on the GWT forums on Google Groups and some of the Eclipse project configuration files in SVN contain references to a "gwtNature" in a com.google package. This presentation went a tantalizing step further and included actual demonstration of the plugin's JSNI syntax highlighting and refactoring abilities, among other things. I wish we could get our hands on an early release version of the plugin, even an alpha or pre-alpha quality, just to try it out. So far, I haven't seen any firm commitment to a release date.

Several other informative presentations on GWT were given at Google I/O back in May. The GWT sessions are listed in the "APIs & Tools" track. The live sessions were a pleasure to attend and I highly recommend the videos, which I've referred back to on occasion since.

Introducing GwtCompilerTask

One of the first things I did when I started working with GWT was to figure out how to compile an application. I don't mean running the myApp-compile.[cmd|sh] that the setup utilities create. I mean ripping apart those compile scripts and writing an Ant script to do it. Here's how in a nutshell:

<target name="gwtc">
  <java 
      classname="com.google.gwt.dev.GWTCompiler" 
      classpathref="classpath.gwt" 
      fork="true">
    <arg value="com.foo.gwt.myapp.MyApp" />
  </java>
</target>

But this past weekend, I found I needed something a little more powerful. I was writing a build target to compile all of the demos in the GWT Incubator. I wanted to avoid having to explicitly list all of the demo modules and use a <java> task call for each one. The best way to find demo modules seemed to be starting from the demo source root directory and scanning for .gwt.xml files. Ant has a <foreach> task that will do just that. The problem then was that <foreach> identifies the module files (com/foo/gwt/myapp/MyApp.gwt.xml), but GWTCompiler requires the logical module name (com.foo.gwt.myapp.MyApp). Ant is great for manipulating files, but it doesn't have much to offer in the way of runtime String manipulation. The solution? Leverage a more full-bodied programming environment. Like Java.

So I wrote a custom Ant task to handle invoking the GWTCompiler and to bridge the gap between the module's file name and it's logical name. Here's what the demo build looks like:

<target name="gwtc" depends="compile">
  <!-- define the GwtCompilerTask -->
  <taskdef 
      name="gwtc" 
      classname="com.google.ant.GwtCompilerTask">
    <classpath>
      <path path="${project.bin}" />
      <pathelement location="${gwt.dev.jar}" />
    </classpath>
  </taskdef>

  <property name="gwtc.vm.maxMemory" value="512m" />

  <!-- gwtc supports compiling with moduleName or moduleFile.
       Use of moduleFile requires setting src so that the 
       logical module name can be determined by comparing the
       moduleFile path to the source root path. vmMaxMemory
       sets the -Xmx VM argument. -->
  <gwtc src="${gwtc.src.dir}"
        out="${gwtc.out.dir}"
        moduleFile="${gwtc.module.file}"
        style="${gwtc.js.style}"
        vmMaxMemory="${gwtc.vm.maxMemory}">
    <!-- gwtc supports nested classpath -->
    <classpath>
      <path path="${gwtc.src.dir}" />
      <path path="${project.src}" />
      <path path="${project.bin}" />
      <pathelement location="${gwt.user.jar}" />
      <pathelement location="${gwt.dev.jar}" />
      <pathelement 
        location="${gwt.tools}/lib/w3c/sac/sac-1.3.jar" />
      <pathelement 
        location="${gwt.tools}/lib/w3c/flute/flute-1.3.jar" />
    </classpath>
  </gwtc>
</target>

<target name="build.demos">
  <property 
      name="demo.src.dir"
      value="${project.root}/src-demo" />
  <property name="demo.out.dir" value="${project.root}/demo" />
  <property name="demo.js.style" value="PRETTY" />

  <!-- Scan for any file under src-demo ending in .gwt.xml. For
       each file, invoke the gwtc target. The full path to the
       file is passed to gwtc target as gwtc.module.file -->
  <foreach target="gwtc" param="gwtc.module.file">
    <param name="gwtc.src.dir" value="${demo.src.dir}" />
    <param name="gwtc.out.dir" value="${demo.out.dir}" />
    <param name="gwtc.js.style" value="${demo.js.style}" />
    <path>
      <fileset dir="src-demo">
        <include name="**/*.gwt.xml" />
      </fileset>
    </path>
  </foreach>
</target>

GwtCompilerTask can also be used for building regular single-module GWT applications. GwtCompilerTask is available in the GWT Incubator. You will need to build gwt-incubator.jar from trunk at revision 1133 or later.

Taking Command of Your GWT Application

I love interfaces in Java. When used properly, they make for code that is highly cohesive and loosely coupled. Classes that implement interfaces or declare method parameters with interfaces are easier to reuse. One of my favorite interfaces in the Google Web Toolkit is Command. Command has one method:

public void execute();

That's it. A Command can be executed. Command, like the HasValue interface in the GWT Incubator is a very simple interface. So often in programming it is these simple building blocks that give us the greatest opportunities. Let's build on Command and another basic component, Button.

public class CommandButton extends Button {
  public CommandButton(final String html, final Command command) {
    super(html);
    addClickListener(new ClickListener() {
      public void onClick(Widget sender) {
        command.execute();
      }
    });
  }
}

There. Now we can create Buttons that execute a Command when clicked. If your application uses a lot of Buttons, that saves a lot of code for adding ClickListeners. And the code you might've put in those anonymous ClickListeners is now safely encapsulated inside a reusable Command class. I use some variation on CommandButton in almost every application I build. Here's another one I use:

public class CommandLabel extends Label {
  public CommandButton(final String text, final Command command) {
    super(html);
    addClickListener(new ClickListener() {
      public void onClick(Widget sender) {
        command.execute();
      }
    });
  }
}

Almost identical to CommandButton, isn't it? This one just uses a text Label instead of a Button. You can do the same with an Image if you want (and I have). I even wrote one with a ToggleButton.

At some point, I'm going to find the time to start a library project with all of these simple Widget extensions.

public int getValue()

This week I committed my first change as a member of the GWT Incubator project. That change was to introduce an interface, HasValue. This by itself is no monumental achievement. The interface is very simple:

public interface HasValue<T> {
 T getValue();
 void setValue(T value);
}

But this simple interface will facilitate the creation of more complex features such as libraries for data binding or validation.

HasValue provides a layer of abstraction around Widgets, allowing access to the underlying data model through a common API. HasValue works with simple Widgets and data types as well as complex data types and composite Widgets.

Consider two Widgets (both from the Incubator) for selecting a Date value:

DatePicker picker = new DatePicker();
DropDownListBox<Date> dropDown = new DropDownListBox<Date>();

Both implement HasValue<Date> so you could, for example, write a BirthdayValidator that ensures the selected Date is before today. This validator would have a HasValue<Date> parameter and could validate either of the two Widgets above, or any other Widget implementing the HasValue<Date> interface, without additional coding to support those Widgets.

Right now HasValue exists only in the Incubator, but there is support for including it in the next GWT release, version 1.6. Hopefully that release will see HasValue implemented by most of the standard GWT Widgets. In the mean time, I would love to see how GWT application developers use HasValue in their own projects. If you haven't worked with the Incubator before, you'll want to setup the project locally so you can build the latest features. Here's where to start:

Setting up the GWT Incubator project