Monday, November 01, 2010

Loom 2.2 has been released

We have just released Loom 2.2 with a lot of stuff to make web development easier:

Better javascript/CSS resource bundles


Loom has been supporting javascript and CSS dependencies for some time, and now they just got easier (think sprockets):

JSP file:
<l:css resource="style.css"/>
<l:script resource="main.js"/>

style.css:
/* 
// @include "myfile.css" 
// @include 'classpath:/mypackage/file2.css' 
*/ 

main.js:
// @include "myfile.js" 
// @include 'classpath:/mypackage/file2.js' 

These dependencies can now be redefined without restarting the server. In production environments they will be concatenated, minified and gzipped - which brings us to the next point:

More and better features

Added support for Google Closure Compiler


According to multiple sources Google Closure Compiler produces a better compression rate than YUI Compressor. This is nice, but what really got us is the awesome error reporting which even warns about IE gotchas (trailing commas, anyone?).

Google Closure compiler is now the preferred javascript compressor and will be used if it is present in the classpath. For CSS, YUI compressor is still the (only?) solution.

New Ajax Paged Table


Loom includes some great server-side paged components. With 2.1 we introduced a new Ajax paged list where the whole pagination process was performed by javascript code, and with 2.2 we are extending this to paged tables:

var paged = new loom.ui.PagedTable($('container2'), { 
        url: '<l:url mapping="Action.event" decorator="link-only"/>', 
        columnNames: [ 'timestamp', 'contents', 'user.name', 'user.avatar' ], 
        // optional fields: specify CSS class names and cell renderer
        columnClassNames: ['date'], 
        columnRenderers: [ function(o) { return o.timestamp == null? '' : new Date(o.timestamp); } ] 
  }); 

This is an alternative to server-side paging. Just use the solution that suits you.

Better fluent interfaces


Some interfaces got better at handling HTTP headers and cookies:

// the bad: 
Resolution res = forward() 
   .set("foo", "bar"); 
res.addCookie("baz", "bar"); 
return res; 

// the ugly: 
getResponse().addHeader("baz", "bar"); 
return forward(); 

// the new API:
return forward() 
   .set("foo", bar") 
   .addCookie("baz", "bar") 
   .addHeader("Content-Type", "application/javascript") 
;

CacheControl has also been improved:

// Before: 
CacheControl c = new CacheControl(); 
c.setCacheYears(10); 
c.setLastModified(new Date()); 
return forward().withCacheControl(c); 

// After: 
CacheControl c = new CacheControl()
   .withYears(10)
   .withLastModified(new Date());
return forward().withCacheControl(c);

Others


There is a lot of smaller improvements such as:
Work on the next release (2.3) has already started, including the redesign of some internals to address Google AppEngine development with Guice. It's exciting!

No comments:

Post a Comment

Something on your mind?