May 29 2007

Developing a Real-World Web Application with NetBeans 5.5 Visual Web Pack

David Botterill walk the audience through the design, analysis, issues, and resolutions of creating the NetBeans plugin portal site using NetBeans, of course, and JavaServer Faces (JSF). Some of David’s best practices for JSF development include are to come up with a preliminary set of requirements, use best guess at page design and page flow in prototype to get feedback, solidify the UI during analysis (the UI will effect the architecture), use Firefox Firebug to debug tricky HTML, CSS, and JavaScript.

Many of the issues described in by David seemed to have been web pack bugs that have since been fixed. That said, he did suggest some common pitfalls and how to avoid them. David suggested to start with Plain Old Java Objects, POJOs, not with relational tables and foreign keys, and joins, etc. David also stated that getting started with JPQL queries was a bit difficult, if for no other reason than it is something new that he had to go through. David found it difficult to have a button for a form which you can just press the enter button to submit it because there was no submit button on the form. Be aware of session timeouts, don’t make assumption in your software about the state of the session, always test for it. Be diligent about separating your CSS in separate files from your HTML. If you have a web application that relies heavily on the GET method then reevaluate using JSF because it makes it difficult.

Finally, David believes that for web applications resiliency is better than efficiency.

Technorati Tags: , , , , , ,


May 28 2007

Using jMaki in a Visual Development Environment

The jMaki project started as a wrapping utility for JS libraries and widgets. The j stands for JavaScript and maki comes from the Japanese word for wrapping, maku. The intent of jMaki is to promote clean seperation between content, style, and javascript and do so in an abstraction layer that lends itself well to a component model. jMaki is a client-server framework with support in PHP, Rails, or Java web applications.

jMaki has nice IDE support in NetBeans with plenty of wizards to get you started. Since jMaki provides a nice component model you can use the visual editor to wire together the UI of a web application in your IDE. Since a big part of web application development is getting the layout right, jMaki comes with several layouts right out of the box, all you do is select the template you want to use from the IDE.

To wrap a custom JavaScript library with jMaki you will need to create a jMaki widget. A jMaki widget uses the convention, instead of configuration, which is basically a folder containing three files, a HTML template, a CSS style, and JavaScript behavior. jMaki already has support for popular JavaScript libraries such as ExtJS, YUI!, Dojo, etc.

Greg Murray stated that he developed jMaki because he “wanted the reload button to be the redeploy button.” Well, since HTML, CSS, and JS aren’t compiled, that is easy to do. One button redeploy is not the stregth of jMaki, what jMaki has going for itself is that you can visual develop a web application using NetBeans and that this wraps several libraries in a easy to use fashion. jMaki also allows you to mix and match different JavaScript libraries together and communicate with each other using Glue. jMaki provides a common ground for integrating multiple of the currently existing AJAX libraries.

There is a jMaki on Rails plugin available and a PHP library.

Technorati Tags: , , , , , , , , , , ,


May 28 2007

CommunityOne 2007: G2One

The G2One, Groovy and Grails mini-pre-JavaOne conference, was put together by the folks behind No Fluff, Just Stuff conferences. The G2One mini-conference brought together Guillaume LaForge, the Groovy project lead, Graeme Rocher, Grails project lead, and Groovy in Action author Dierk Koenig amongst other Groovy developers and evangelist.

Guillaume started the event by proving a quick introduction of Groovy and going into the details of the upcoming release. Groovy provides semantic sugar and sweetness to the Java VM. Groovy is Java-like and compiles down to Java to byte code but with the added bonus of the GDK, the Groovy Development Kit. You can mix and match Java/Groovy classes seamlessly, no bridge/connector required. I think that Groovy is what Java 3 should and might be. For example, Groovy provides string substitution, array and map literals, and regex literals. There are Eclipse plugins for Groovy that come with code completion, navigation, and highlighting. Groovy 1.1-beta has support for annotations.

Graeme talked about the currently available Grails 0.5 release. Grails builds on top of Groovy as the language used in the models and controllers, Spring for the Inversion of Control container, Hibernate for the Object Relational Mapping, Quartz for task scheduler, and Sitemesh for templeting. Grails comes with an embedded Jetty servlet container and embedded HSQLDB database for quick turn around agile development. Graeme stated that most of the behavior in Grails is provided by plugins. So what is new in Grails 0.5? Command Objects in controllers. List and map support in GORM. Cascading validation. Script event hooks. Converter plugin to automatic convert models too XML, JSON, or RSS.

There was a series of rapid fire demoes by Guillaume, Graeme, Dierk, and other Groovy developers. One demo used the SwingBuilder groovy class to mashup GMaps and Flickr data. The demo used XMLSlurp to consume XML RSS feeds. Remixing and mashing up Google Maps and Flickr is like the ‘Hello, World’ first program of Web 2.0 mashups. When demoing the Swing-based mashup, Dierk Koenig said of the aesthetics of his demo, “This is what happens when you program in Swing, the first attempt is usually ugly.”

Technorati Tags: , , , , , , , , , ,


May 27 2007

CommunityOne 2007: JRuby: Understanding the Fuss

Fellow Sun engineers Tor Norbye and Charles Nutter presented on the past, present, and future fuss of JRuby at CommunityOne 2007. To understand where JRuby is heading, the presenters painted a clear picture of the Ruby programming language. Ruby is a dynamically typed pure object-oriented language originally written by Yukihiro ‘Matz’ Matsumoto. The Ruby programming language is an expressive, powerful, and easy to learn, read, and write.

Tor and Charles gave a quick tour of the Ruby language features such as string substitution, modules and mixins, open classes, meta-programming, duck typing, literals for arrays and maps, and code blocks. Ruby is an incredible flexible and expressive language. The more expressive the language, the less code you’ll end up writing and maintaining.

Tor also demoed his work with NetBeans support for JRuby. NetBeans includes code highlighting, code completion, and documentation support for JRuby. While demoing NetBeans and thinking of JPA Tor Norbye said, “I wish they had annotations in this language.”

Technorati Tags: , , , , , , , ,


Apr 9 2007

Software Development Environment

I had to update our project wiki and detail our current software development environment. I found that we are lagging a bit behind the latest Java technologies and tools, but from a business perspective I think it is hard to up sell existing customers just so that developers can use the latest Java language features in their code. Large software clients usually invest a lot of time and money into the applications they use for their business processes and can’t upgrade based on the schedule of software tool vendors.

Thinking about the current state of tech tools, I wanted to jot down the tools of the trade that I use on a day to day basis.

Java Development/Work
Java 1.4.2
Maven 1.0
Eclipse 3.1.2 with Perforce plugin
TeamTrack

Java Development/Home
Java 1.5
Maven 2.0
Eclipse 3.2.1 with Subclipse, Groovy, JavaCC, and Aptana plugins
Subversion 1.3

Ruby on Rails
Ruby 1.8.4
Rails 1.2.2
RadRails 0.7.2

Database
SQL Server 2005 Express
Oracle 10g Express
Mysql 4.1.15

Firefox Plugins
Firebug 1.04
Web Developer 1.1.3
Selenium IDE 0.8.7

Miscellaneous Editors
SciTE 1.70
Komodo Edit 4.0
TextWrangler 2.2

Collaboration
Skype
Google Apps

Technorati Tags: , , , , , , , , , , , , , , ,


May 21 2006

Google Web Toolkit Tutorial: The Break Down

There was a lot of buzz at JavaOne regarding the Google Web Toolkit (GWT). Basically, GWT allows a developer to write a AJAX powered web application in Java!! The Java code gets ‘compiled’ to a set of plain old text files containing your JavaScript code. For example, the GWT will translate your rollover actions written in Java to JavaScript functions. This confused me for a second so I’ll stress again that you compile your web application written in Java to plain old JavaScript and HTML that can run in any browser.

What this means is that if you are a Java developer you don’t have to learn JavaScript and all the idiosyncrasies of every browser to develop a stable and reliable AJAX web application.

To get started download the GWT from Google, configure it with Eclipse, and create a new web application.

I created and imported into Eclipse a project called WebApp. In my Package Explorer under webapp > src > com.juixe.gwt I have a public directory that contains my WebApp.html. This file was created by the applicationCreator batch file provided with the GWT. For the purpose of this walk through I modified my WebApp.html as follows:

<HTML>
  <HEAD>
    <TITLE>HTML for WebApp</TITLE>
    <!-- You need this to reference your GWT module -->
    <META name='gwt:module' content='com.juixe.gwt.WebApp'>

    <SCRIPT language="javascript" src="gwt.js">
    </SCRIPT>

    <STYLE></STYLE>
  </HEAD>

  <BODY>
    <H1>My WebApp</H1>
    Any text or HTML goes here.
    <DIV id="changeOnRollOver"></DIV>
  </BODY>
</HTML>

The HTML is simple to describe itself. I have a body that can contain any HTML. I can use CSS style sheets. The only tag that seems out of place it he meta tag.

<meta name='gwt:module' content='com.juixe.gwt.WebApp'>

What I would like to do at this time is write some some GWT based Java code to modify the text inside this DIV identified as changeOnRollOver. To do this I had to modify WebApp.java file under webapp > src > com.juixe.gwt.client. Here is the code for WebApp.java:

/**
 * Entry point classes define onModuleLoad().
 */
public class WebApp implements EntryPoint {

   /**
    * This is the entry point method.
    */
   public void onModuleLoad() {

        // Create Label widget
      final Label roller = new Label(\"Default value\");

        // Associate HTML element to GWT widget
      RootPanel.get(\"changeOnRollOver\").add(roller);

        // Add mouse lister to label widget
      roller.addMouseListener(new MouseListener() {
         public void onMouseEnter(Widget sender) {
            roller.setText(\"Entered element...\");
         }

         public void onMouseLeave(Widget sender) {
            roller.setText(\"Leaving element...\");
         }

         // Do nothing
         public void onMouseDown(Widget sender, int x, int y) {}

         // Do nothing
         public void onMouseMove(Widget sender, int x, int y) {}

         // Do nothing
         public void onMouseUp(Widget sender, int x, int y) {}
      });
   }
}

Let me break this code down. This WebApp class needs to implement the onModuleLoad method of the EntryPoint interface. This is called when you page loads. I think of this method as the equivalent to the JavaScript onload event handler. The first thing I do in the onModuleLoad is create a GWT Label widget called roller. There are a lot of widgets such as labels, buttons, check boxes, tab panels, menu bars, trees, and a whole slough of other widgets. After I instantiated a Label associates the roller Label I just created to my DIV identified as changeOnRollOver in my HTML file. You can associate any GWT widget to any HTML element using code similar to the following:

RootPanel.get(elementNameStr).add(gwtWidgetObject);

The last thing to go over is how to wire functions to widget events. In the above code, I register a MouseListener to it via it’s addMouseListener method. For this example I am not interested in all the mouse listener methods but I still need to implement them. I am only interested in the onMouseEnter and onMouseLeave events. For this events I will just change the text of the roller Label to indicate if I am entering the element or leaving it.

Here is a suggestion to the GWT team: Add a MouseAdapter to the API, please!!!

I can run and debug this code from Eclipse or I could compile it using the WebApp-compile batch file to create the JavaScript and HTML files required to test this in my favorite browser. The WebApp-compile batch file will create a www folder under my webapp project (you might need to refresh you project in Eclipse).

This a somewhat trivial example but if I wanted to do the same thing in notepad using just HTML and JavaScript this is how it would look:

<HTML>
  <HEAD>
    <TITLE>HTML for WebApp</TITLE>
    <STYLE></STYLE>
  </HEAD>

  <BODY>
    <H1>My WebApp</H1>
    Any text or HTML goes here.
    <DIV
      onmouseover=\"this.innerHTML='entered'\"
      onmouseout=\"this.innerHTML = 'left'\">
    &nbsp;
    </DIV>
  </BODY>
</HTML>