May 18 2007

CommunityOne 2007: Swing GUI Building with Matisse: Chapter II

This session was presented by Joshua Marinacci, Shannon Hickey, Hans Muller and other Sun technical leads behind NetBeans, Swing Application Framework, and Beans Binding. This session was practically a demo of NetBeans GUI Builder improvements and support for JSR 296: Swing Application Framework and JSR 295: Beans Binding.

The logic behind the Swing Application Framework is to provide a framework to help novice swing developers get up and running. The desktop client API stack is pretty large and intimidating when starting a Swing application from scratch. Swing Application Framework can be explained in an hour, and is small and simple enough for small to medium size applications.

The demo demonstrated how to use GUI Builder to construct a Swing Application Framework-based application mashup that downloads images from Flickr based on a given search criteria. They tied the model with the UI with Beans Binding. Beans Binding keeps two properties from two objects in sync. Shannon Hickey, the specification lead of JSR 295 said that “Beans Binding is going to be great for Swing when finished.” Beans Binding describes the source properties using Java Expression Language. The Beans Binding will accommodate objects that don’t follow the beans pattern, such as maps which will be treated as dynamic beans. Beans application model to Swing UI components.

These guys built a Flickr client using NetBeans, Data Binding, Swing Application Framework in four minutes flat.

Technorati Tags: , , , , , , , ,


May 18 2007

CommunityOne 2007: Ajax Applications Made Easy with jMaki and Scripting

This technical session at CommunityOne 2007 introduced me jMaki, a project under the GlassFish umbrella. Project jMaki is a lightweight AJAX framework that wraps JavaScript libraries and in such provides a common interface to any and all JavaScript code. jMaki proposes a convention, over configuration, to wrap any third-party or custom JavaScript library as a jMaki widget. In other words, jMaki is a widget model for creating, using, and wrapping existing JavaScript functionality. jMaki is also available as a helper in Rails, and as a function in PHP, as well as a component in JSF.

Out of the box, jMaki comes with layout and theme support. In addition to layout, jMaki has a XMLHttpProxy (XHP) feature that allows you to bypass the pesky same-origin policy restriction.

Should you use jMaki? Yes. jMaki does all the hard work so that you can mix YUI!, Scriptaculous, Spry, and any other Ajax library together seamlessly. jMaki provides visual development support with plugins for Eclipse and NetBeans. jMaki also provides a common widget model for JavaScript libraries so that you don’t have to learn each more than you have to to work with any one of them.

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


May 17 2007

CommunityOne 2007: Lunch with the Java Posse

The JavaPosse podcast is hosted by Tor Norbye (Sun), Carl Quinn (Google), Joe Nuxoll (Apple), and Dick Wall (Google). The regular format for the show is for the posse to run down trough and pontificate the current news in the Java world. For this live recording of the Java Posse podcast the posse adopted the Top Ten count down made famous by David Letterman. Some of the posse’s top predictions for JavaOne 2007 included mobile mayhem, desktop Java push, and that applets will no longer suck.

According to the posse, the top missing features in Java include the missing LINQ, cross platform solutions for recording and playing back audio, device support for USB and FireWire, browser level Swing HTML rendering, language level properties and events, component model for the desktop, component model for the web, component model for the mobile, and more importantly a consistent component model for all. Additional missing features in the language include true generics, regexp literals ala Groovy, multiple return values or parallel assignment, closures, @Nullable annotation, type inference ala Scala, invoke dynamic, and modules and super packages.

The posse then listed the top APIs to nuke from Java which include anything related to date and calendar, java.awt.List, java.awt.*, java.beans.*, java.swing.LookAndFeel, java.util.Stack, java.util.hashtable, the close method if it throws an exception, java.io.File since it is just a path, cloneable, binary serialization, Enumeration, and CORBA.

The top software industry pet peeves according to the Posse include the not invented here syndrome, paper architects (if you can’t code, retire), developers with nothing left to learn, IDE zealots, framework zealots, snap judgment of technology, frivolous patentry, lack of User Interface sex appeal, coding styles, meetings, tHE cAPS lOCK mUST dIE, unskippable intros, and general lack of manners.

Here are some memorable quotes from the posse members.
The definition of Hell is working with dates in Java, JDBC, and Oracle. Every single one of them screw it up. — Dick Wall
This project is running late, quick lets have a meeting. — Dick Wall
The recommendation I would give you is not to use Swing, but to be using a rich application platform like NetBeans. — Tor Norbye

Technorati Tags: , , , , ,


May 16 2007

CommunityOne 2007: Getting Started and What’s New in GlassFish v2

The first technical session I attended at CommunityOne 2007 was about GlassFish, the JEE5 reference implementation for JSR 244. According to the session speaker, GlassFish is more than a reference implementation. The value of GlassFish is that it is open source, community driven, and production quality JEE5 Application Server. JEE5 is a simplification of J2EE, the previous incarnation of the Java Enterprise Edition. JEE5 simplifies enterprise development by leveraging Plain Old Java Objects (POJO) described with annotations. Annotations are first class language construct in java 5.

The current release of GlashFish, v2, provides better performance, faster startup time, out of the box load balancing, cluster management, and built-in fail-over. Under the covers, the GlassFish Application Sever is powered by Grizzly, EJB 3.0, and JPA. GlassFish is really a community effort with many supporting side projects such as jMaki, Slynkr, Blogapps, and Phobos.

Technorati Tags: , , , , , , ,


May 16 2007

Welcome to CommunityOne 2007

For several years now, Sun has put on a NetBeans Day one day prior the start of JavaOne. This year, they rebranded NetBeans Day and it’s spin off GlassFish Day into CommunityOne. CommunityOne is a open and free event, a mini-JavaOne if you will. This year, the featured speaker for the General Session was Tim O’Reilly. Rich Green, Vice President of the Software division at Sun, welcomed the attentive audience by talking about the new open source culture at Sun. Rich said, “Simplicity and access is far more important than technological perfection.” After a brief introduction Rich welcomed Tim O’Reilly to the stage.

Tim started by asking the crowd, “How many of you use Linux? How many of you use Google?” Tim feels that Google, Craigslist, Yahoo, Ebay, Amazon, and all those web applications share a common thread. He feels that they are “data aggregators, not packaged software.” They are not so much important as applications but more so as services. Just having the source code to Google’s Page Rank algorithm does not mean you will replicate the success of Google. These services use the network effects of User Generated Content to gain market share. Tim reminded the audience that value has moved from hardware to software, and how it is now moving from software to services. But with these services end users aren’t just entities that mindlessly contribute content, they become co-contributers and this has been made self evident by the recent Digg Revolt. Digg users went up in arms regarding the censorship of stories listing a HD DVD key.

Tim O’Reilly said that Web 2.0 is about bionic software powered by people. Digg, Flickr, Delicious, and these other Web 2.0 sites are powered by people and leverage an architecture of participation as described in The Cornucopia of the Commons.

In describing the architecture of participation, Tim noted the tendency of web services to be stuck in perpetual beta. Microsoft might have a better idea of perpetual beta when they think of it as live software. Online web applications grow and evolve organically. Small and agile teams are more able to evolve software organically. Tim said that Amazon has a rule of thumb for limiting the size of a team to the number of techies that can be feed by two pizzas. Although not described as such, Google uses two pizza teams on their products such as Google Calendar.

There are two other comments made by Tim that I though interesting. The first comment I wanted to capture was that “we are coming to the end of cheap outpouring.” Then he quoted a colleague that you can make money on the long tail, but no t in the long tail.

Technorati Tags: , , , , , , ,


May 2 2007

Unobtrusive JavaScript with Prototype and Behavior

If you are familiar with web application development you may already be familiar with the Model-View-Controller (MVC) design pattern. The MVC pattern aims to separate your server side business logic from your presentation code from your data model. The by-product of web applications are the HTML, CSS, and JavaScript pages generated and delivered to the client browser. Historically in the early Web 1.0 days, a web page’s content, style, and behavior would all be intertwined and glued tightly together in the HTML, do you remember the font tag? Somewhere along the way to the Web 2.0 network, developers opted to remove the style attributes from the content by using Cascading Style Sheets (CSS) classes.

CSS allows you to create style classes whose concern is purely a way to describe the size, font, color, and look of whatever content that uses the class.

.makeMeBeautiful {
  color: #00248F;
  text-decoration: underline;
  background-color: #FFFFFF;
  font-size: 1.1em;
}

To apply a CSS class on an HTML element you use the class attribute.

<div class="makeMeBeautiful">Hello, World</div>

The idea behind Unobtrusive JavaScript (UJS) is to remove JavaScript events, such as onclick and onmouseover, from the content in the same fashion as the style attribute. Unobtrusive JavaScript uses the class and id attribute of HTML tag elements to find and assign JavaScript events in a inconspicuous fashion, just as with CSS.

If you think of the HTML content as the Model, the CSS stylings as the View, and JavaScript behaviors as the Controller of MVC, then it makes perfect sense to remove all traces of style attributes and JavaScript events from the HTML.

Unobtrusive JavaScript with Prototype

Traditionally if you wanted to add a JavaScript onclick event to a HTML element you would do so by adding the onclick attribute. Unobtrusive JavaScript recommends that you instead find the tag by the class or id attribute and assign the even programmatically.

// Logic to execute when the end user
// clicks the element
function myOnClickFunction(elem) {
  alert(elem);
}

// Register the onclick event for all elements
// the given class name
window.onload = function() {
  // Find all elements that use that given CSS class
  var elements = document.getElementsByClassName("makeMeBeautiful");
  elements.each(
    function(e) {
      // Assign the onclick method to the element
      Event.observe(e, "click", myOnClickFunction);
    }
  );
}

Note that the above JavaScript code works only when the Prototype JavaScript library is made available.

If your need to add Unobstrusive JavaScript events for a few tag elements and are already using Prototype then the above code will suffice.

Unobtrusive JavaScript with Behavior

For more restrictive selection process of the HTML elements to apply JavaScript events you can use the Behavior JavaScript library. The Behavior JavaScript library is a lot easier and more powerful way to add behavior to HTML elements than Prototype. With the Behavior library you define an associated hash map literal object thingie where the keys are CSS selectors and the value is an initializing JavaScript function. In the initializing function you can add any onclick, onmouseover, onchange, onsubmit, onfocus, onblur, onwhatever event.

var rules = {
  '.makeMeBeautiful' : function(elem){
    elem.onclick = function(){
      alert(elem);
    }
  }
};

Behaviour.register(rules);

The power of the Behavior library is that you can create the behavioral rules using CSS selectors to choose the tag elements for which to apply a given set of JavaScript functionality. Both the Prototype and Behavior code shown up to this point will apply the JavaScript onclick behavior on all elements that use the given CSS class. With the Behavior library you can use CSS selectors to restrict what elements to apply the behavior to. For example, to apply the onclick behavior only for div elements you can use the following rule.

var rules = {
  'div.makeMeBeautiful' : function(elem){
    // Your code here...
  }
};

The idea behind Unobtrusive JavaScript is to separate the HTML, CSS, and JavaScript according to responsibilities in a similar fashion as the MVC design pattern suggests. UJS also helps in the maintenance of large sites and it allows for graceful degradation.