Improved multi-monitor support for Eclipse 3.4

February 14th, 2008

Here is a good reason to await Eclipse 3.4:
http://wiki.eclipse.org/Improve_multi-monitor_support

A First Look at Mylyn

February 6th, 2008

Finally got around to spending some time with Mylyn, the popular Eclipse plugin that helps you manage tasks and provides integration with task repositories like Bugzilla, JIRA, Trac, and others.

For me the CVS features built-in in Eclipse have always provided a high value day in day out. Integrating with bug tracking repositories is a further step in the same direction allows me to perform queries against JIRA for example to see issues I’m working without going to an external browser. This feature alone makes it worth having this plugin.

Taking that a step farther Mylyn provides intelligent, task sensitive, context switching. That is to say it hides or shows only what’s relevant to the task at hand in views such as the Project Explorer where you might normally browse through hundreds of files. Instead you see only the few files and methods you care about. This adds a certain kind of intelligence to Eclipse, the kind of intelligence I remember a long time when I used IntelliJ (oops, did I say that out loud?)

To learn more I recommend the Mylyn User Guide, which is actually not easy to find like anything else on eclipse.org:
http://wiki.eclipse.org/index.php/Mylyn_User_Guide

One oddity for Linux users… Using Alt+Click (mentioned a lot in Mik Kersten’s articles on IBM DevelopreWorks) just didn’t work for me. I kept trying without any luck. Finally I discovered Alt+Click is already mapped in GNOME desktop for moving windows and needs to be disabled. Also I had to hold down the Win key (Windows logo on it) together with Alt+Click and voila it worked! The User Guide has both of these documented.

Spring WS and Java Web Service Standards

December 7th, 2007

I will be giving a talk at The Spring Experience comparing Spring Web Services to Apache Axis2 and CXF and expect the question about Java WS standards to come up. Why doesn’t Spring WS support Java standards? One way to look at this is to understand there are two types of Web Services: code-first and contract-first. Both use the same underlying mechanism (WSDL, SOAP, XML) but conceptually they are far apart. Code-first is really a form of remoting in which XML is merely a wire format. Contract-first on the other hand means much more focus on designing an effective contract independent of the implementation.

Consider standard XML schemas used in various industries such as Health Level 7 (HL7), Univeral Business Language (UBL), or even the Global Justice XML Data Model. These contracts are designed so that disparate business entities who need to exchange data can agree on common type definitions (sometimes that’s easier said than done). This involves a loosely coupled source and destination who need to have a stable contract and be able to evolve independent from each other.

Code-first on the other hand is easier to imagine in situations in which a source and a destination are closely related. For example a .NET client and Java service of the same application are really not that concerned with loose coupling but more with interoperability. What’s confusing is that while this is really a form of remoting it is also considered a Web Service. This terminology is fine but just because WSDL is involved in the exchange don’t expect that same WSDL to be an effective Web Service contract. That is to say one that will remain stable over time.

Going back to the question about Java Web Service standards. The standards are beginning to reflect the importance of the contract-first approach. For example JSR-181 defines annotations to influence the generation of WSDL from a Java endpoint. There is also the Provider interface that allows dealing with a message as a DOM tree. While this is an improvement over previous versions, contract-first remains a secondary topic. This is perhaps reflected in the fact JSR-181 defines the Start with Java development model as required while the Start with WSDL is left as optional.

Lastly to think that Spring Web Services is somehow against Java standards would be incorrect. They’re simply focused on different things. In fact Spring Web Services relies on a number of existing Java standards such as a simple servlet deployment model, JAXP, JAXB, XPath along with many other Java XML API’s and data binding toolkits.

For a good treatment of the Java Web Service standards I highly recommend Mark Hansen’s “SOA Using Java Web Services”. It is a fair, in-depth assessment that will give you a good idea about just how “simple” Web Services are. You can also read about some of his personal travails with the standards online in this blog entry.

Adding Ajax Behavior to the Displaytag Library

October 14th, 2007

The JSP custom tag library Displaytag is very good at one thing – rendering HTML tables including links for paging, sorting, and data export to different formats (CSV, Excel, XML). This is very useful for building JSP views but its value is diminished on pages with Ajax behavior because each of the generated page and sort links cause the entire page to be reloaded.

You can use AjaxTags – another JSP custom tag library to make a Displaytag table re-render itself through an AJAX request and that works fine but eventually you might outgrow the approach of wrapping JavaScript code with JSP custom tags and may want to gain further control of client-side behavior. Furthermore AjaxTags requires use of the Prototype JavaScript library, which may or may not suite your deployment scenario.

Actually adding AJAX behavior to a Displaytag table is not that difficult. The code shown below uses the Dojo toolkit but the demonstrated technique can be implemented with any of the other JavaScript toolkits that have remoting capabilities. This is what you need to:

  1. Add a div tag around the Displaytag table.
  2. Declare the JavaScript function shown below and pass the div id to it.
function ajaxifyDisplayTag(targetId) {

  var onclickHandler =
    function (event) {
      event.preventDefault();
      dojo.xhrGet({
        url: event.target.href,
        load: function(data){
            dojo.byId(targetId).innerHTML = data;
            dojo.parser.parse(dojo.byId(targetId));
            ajaxifyDisplayTag(targetId);
        },
        error: function(data){
            alert("HXR Error in ajaxifyDisplayTag" + data);
        },
    });
  };

  dojo.forEach(
    dojo.query('a', dojo.byId(targetId)),
      function(aTag) {
        console.debug('Set onclick handler for ' + aTag);
        dojo.connect(aTag, 'onclick', onclickHandler);
    }
  );
}

That’s it!

In short what the above function does is it finds every hyperlink within the specified div tag and connects a pre-defined handler to its onclick event. The handler prevents the actual event from taking place and instead fires an AJAX request to the same URL. The returned data is then used to replace the content of the target div tag. Since the returned HTML content is also a Displaytag table we need to invoke the above function on the returned HTML content to ensure its links are connected to our onclick handler.

Of course if your AJAX toolkit already has a data grid widget then you don’t need any of the above. Dojo users are about to get one very soon as part of Dojo the 1.0 release.

3D Desktop Effects with the Beryl Manager on Ubuntu

September 29th, 2007

I’ve known about Beryl for some time but have been skeptical about installing it. 3D effects and other desktop eye candy is cool but it doesn’t trump productivity and stability.

It turned out I was wrong on both of these points. I finally made the move to Beryl and was surprised by the results, which are quite good. Most importantly I’ve since found lots of productivity-related features in Beryl that go beyond “eye candy”. Here is a short list:

  1. Rotating among several desktop workspaces is plain cool but it is also very encouraging towards actually utilizing multiple desktop workspaces.
  2. The animation effects on minimizing and closing windows are not to be estimated as a continuous source of geek-type inspiration.
  3. Hitting F9 displays all active windows in the current workspace at the same time (like tiles) so you can pick the one you want. Hitting F8 does the same for active windows in all workspaces. Great stuff! When many windows are opened I hate cycling through!
  4. Using the “Windows” (Super) key in combination with “h” toggles maximizing the window horizontally. I love this one: a life saver for wide-screen laptop users. Doing the same in combination with “v” toggles maximizing the window vertically.
  5. Alt+F8 initiates resizing a window.

There are many other features I haven’t yet come to but I already feel much better about using a great desktop environment.

I am running a T60 Thinkpad with an ATI card (Radeon x1400). I use the proprietary fglrx driver because the free Radeon driver doesn’t support my card well. Given this my path to Beryl required using Xgl to get the 3D effects. You can find instructions by searching for “Beryl Xgl fglrx” or use this link.

Notes from the Rich Web Experience Conference, San Jose CA

September 29th, 2007

I attended a rather direct and revealing talk given by Alex Russel the project lead for the Dojo Toolkit. Given the importance of the Dojo toolkit I was curious to see what Alex would have to say. His talk, titled “Standards Heresy” with the subtitle of “Dojo and the Rise of Open Web Pragmatism” focused at length on standards – what makes a good standard, how does it relate to competition, what makes a good standards body, and so on?

So why the focus on standards? Douglas Crockford, a senior JavaScript architect at Yahoo and creator of JSON gave the keynote speech in which he pointed out a number of failures of rich web development as realized in browsers to date. The notable failures are what he calls “insecurity” or the lack of security on the browser side (e.g. any JavaScript code downloaded as part of your page has access to any other data on the page including cookes, session id’s, etc.) and the lack of advancement in presentation technology (HTML 4.0 dates back to 1999). According to him standards bodies have failed us and it is a striking conclusion considering the fact the number of mainstream browsers isn’t that big.

Continuing on this theme Alex Russel drew out the W3C specification timeline. What we have is HTML 4.01 in 1999, XHTML 1.0 in 2002, DOM 3 Core in 2004, CSS 2.1 in 2007, (CSS 2.0 dates back to 1998). HTML 5 is scheduled for late 2008 and CSS 3 according to him is a mess. Enter WHATWG (Web Hypertext Application Technology Group). This group is focused on evolving HTML in parallel with the W3C HTML working group and the resulting specifications are likely to be implemented in major browsers. Membership in this organization is much more open, there are no fees and in many ways it is much more of a grassroots movement focused on innovation.

Alex characterized ajax toolkits as “symbiotic parasites”, which have continuously pushed the bar of web evolution in terms of what can be done with what we have. This certainly rings true given the existence of ~ 200 ajax toolkits out there. There are efforts to try and bring this ecosystem of toolkits closer together through the work of the Open Ajax Alliance and to me that’s a welcome development bringing many players to the table but what remains is a lack of progress in the underlying capabilities of HTML, DOM, and CSS. Who knows maybe WHATWG will bring about much needed innovation.