Geertjan's Blog

  • April 9, 2007

Lessons Learned from the WebWork Framework (Part 2)

Geertjan Wielenga
Product Manager
A common issue that web framework tooling developers (at least in the NetBeans world) have is this: "How can I let the user most easily put the framework's JAR files on the application's classpath?" Potentially, the user has not put them on the classpath at the time when the New Project wizard is invoked. Ideally, at the end of the New Project wizard, when Finish is clicked, all the necessary JAR files (and only those that are necessary) have been put on the application's classpath (via the Libraries node). (Even more ideally, the user should be able to deploy the application as soon as the wizard is complete... this implies that the JAR files must be on the classpath, otherwise the framework's artifacts won't work.) In the case of Struts and JSF, this is not a problem in the IDE. Why? Well, because all the related JAR files are in the Library Manager by default (since they're bundled with the IDE) so that the Frameworks panel in the New Project wizard needs to do nothing more than get them from the Library Manager.

But what if the JAR files are not in the Library Manager? And what if you don't know where they are? I've been told that soon we'll have a new NetBeans API for dealing with libraries in the framework world (and I am looking forward to that, a lot). In the meantime, how to get those JAR files as painlessly as possible? If you look at NBTapestrySupport, by Andreas in Athens, you'll see that he gives you the option of clicking a link in the Frameworks panel, which takes you to the nbtapestrysupport site, where you can get a ZIP file which, when you unzip it, reveals the JAR files, which you must then register in the Library Manager. That's one approach. Another approach is taken by Petr Pisl (in NBFaceletsSupport). I've more or less followed his approach in my WebWork module. In the Frameworks panel, one gets two tabs (just like in Petr's NBFaceletsSupport module). In the second tab, the Libraries tab, one can either select a folder (which must conform to certain criteria, such as a specific name, so that we can be sure that an appropriate folder is selected by the user) on disk or select one of the registered libraries. Petr's approach is restrictive—he only shows libraries that begin with "facelets". My approach is broader—I show all libraries in the Library Manager, as can be seen here:

The user can either select a library from the drop-down or browse to a folder containing the appropriate JAR files. In the latter case, the JARs are added, programmatically, to the Library Manager (in addition to being put on the current application's classpath). This code, in my module, is not 100% complete, but I'm glad that the majority of it works, thanks to Petr's work for Facelets. This is a relatively small but significant step, which will also be useful when I start looking at support for Grails, during the coming week.

Join the discussion

Comments ( 2 )
  • Andreas Andreou Tuesday, April 10, 2007
    Damn, it's as if you're reading my mind!
    I've been thinking of changing exactly that part and doing something similar to what Petr does - perhaps also having netbeans download the zip on its own.
  • Geertjan Tuesday, April 10, 2007
    That's cool. If NetBeans can somehow get the ZIP on its own, you can use an Ant target to unzip the ZIP. Once it is unzipped, you can install the JAR files in the Library Manager, because you can specify where to unzip to, which means that you'll know where to find the JARs later, programmatically. That will automate the entire process.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.