magpiebrain

Sam Newman's site, a Consultant at ThoughtWorks

Posts from the ‘Development’ category

Finally, after much cursing, shouting, drinking and general annoyance, I have managed to deploy a sample “Hibernate”:http://www.hibernate.org/ application. I must point out here that the problems I had have nothing to do with Hibernate – the documentation is excellent, although their sample application could be packaged a little better (you know, to actually produce a WAR file). The problem I had was with “Tomcat”:http://jakarta.apache.org/tomcat/.

Up to this point I have been using “Jetty”:http://jakarta.apache.org/tomcat/, because it just WORKS. It doesn’t have fancy web-based admin consoles or more config files than you cna shake a stick at, you just put your WAR file in its webapps directory, and restart. At which point it deploys your webapp. Tomcat however doesn’t do that – oh no. Sometimes it ignores your WAR file. Othertimes it unpacks it, but if it does it won’t update this unpacked directory structure if the WAR file changes even if you restart Tomcat. So now my build process has to delete directory structures under Tomcat (I’m sorry, but I am not going to start dealing with unpacked WAR structures – that way madness lies). Oh, and guess what? When Tomcat has an error with a web.xml, it doesn’t tell you which webapp it found the file in! Isn’t that cool! “Now if Jetty was so good, why are you using Tomcat?” you may ask Well, this may be lazyness on my part but the example application had the tomcat config settings and I didn’t feel like working out the equivelent Jetty settings (why can’t these things be standardised?).

Up to then things had gone well – I got “MySQL”:http://www.mysql.com/ installed and running as a service quite quickly. After finally getting the Hibernate example working I had a quick look at getting Hibernate and JBoss working together, but hit the problem that I couldn’t find any documentation explaining how to get “JBoss”:http://www.jboss.org/ working with MySQL – that excersie can wait for another day. Anyway, expect a brief writeup on Hibernate tomorrow – I must say that from what I’ve seen already it looks excellent.

I’ve discovered a variety of solutions for providing rich UI controls for web-based applications of late:

* As mentioned before, the “Display Tag Library”:http://displaytag.sourceforge.net/ provides a JSP custom tag lib for producing CSS-styled tables with sorting, grouping, paging and various export formats. Its easy to use and works well, although could do with some updates to work better with the JSTL and JSP Expression Language.
* “Stuart Langridge’s”:http://www.kryogenix.org/ “DHTML sortable tables”:http://www.kryogenix.org/days/565.html provide a client-side solution to sortable tables – it doesn’t offer as many features as the Display Tag Library but is very easy to use and is great if you can’t rely on server side software, or even if you can but can’t use taglibs
* Via “Zeldman”:http://www.zeldman.com/daily/1003b.shtml#cssdropdowns, “Brainjar(Brainjar – Revenge of the Menu Bar Demo)”:http://www.brainjar.com/dhtml/menubar/demo2.html has some very good looking DHTML drop down menus
* Common Controls provide a set of commercial Tag libraries that integrate with struts to produce some very nice looking controls. The fact that they integrate with Struts is a big plus – one of the problems with the Display Tag Library is that it doesn’t integrate with struts too well. The big problem is that they want a per-server license AND developer licenses. Its not too expensive if you only have one developer and one server, but if you are deploying several servers (as some of my friends are) it can soon get quite expensive. If they offered a flat-fee rate I’d be more interested.
* The “struts menu”:http://struts-menu.sourceforge.net/ is an open source project that as you’d expect gives you nice menus, but isn’t tied to struts any more. Some of the menus it produced did cause problems under firebird however.

I’ve been looking into the topic of (business rule) engines for a while now. Frequently at work I find myself embedding business logic into my code – silly things such as ‘delivery takes and extra day if your in Cornwall’ for example due to time constraints and a lack of a decent framework get written directly into the code. I hate this approach – business rules can be far more fluid than the code itself. Business rule engines such as drools aim to separate these business rules from the code itself. There has been a lot of movement in this area recently – there are a number of commercial rule-based engines in addition to the opensource drools, including “ILOG JRules”:http://www.ilog.com/, “Haley Eclipse”:http://www.haley.com/, “Sandia Jess”:http://herzberg.ca.sandia.gov/jess and “CLIPS”:http://www.ghg.net/clips/CLIPS.html.
“JSR-94”:http://www.jcp.org/en/jsr/detail?id=94 details the API for a Java-based Rule Engine, and is currently at the Proposed Final Draft stage. Implementations of JSR-94 will be forthcoming – ILOG are in the expert group so its fair to assume they’ll have an implementation soon, and the people behind drools have also committed to provide an implementation in the near future.
Due to the other implementations being commercial, I’ve only really looked at drools, although its documentation is good (the “drools guide(Drools – Theory, Usage and Reference [PDF])”:http://drools.org/pdf/drools-guide.pdf gives a good overview not only of drools itself but of rule engines in general) but it seems fairly straightforward..

Whilst reading one of Hani’s “enjoyable rants”:http://www.jroller.com/page/fate/20031029#opensymphony_dirty_laundry over at “The Bile Blog”:http://www.jroller.com/page/fate, I can upon a reference to “Seraph(Atlassian – Seraph)”:http://opensource.atlassian.com/seraph/introduction.html, which at first glance seems to be one of those things that is destined to save me loads of time the next time I write a web app. For some reason, in nearly every web application I’ve been involved with (and there have been a few) I’ve ended up either writing the authentication and authorization code, or at least eneded up doing major work on it – for me its replaced the constant implementations of sortable tables for various companies Swing interfaces.
I’m going to be playing around with some changes to the “Display Tag Library”:http://displaytag.sourceforge.net/ at some point – I might combine it with a web application that uses Seraph to see how it hangs together. It should also be noted that Seraph and The Display Tag Library are the first projects I’ve seen that uses Maven and have gone to any effort to make the resulting sites look like something other than the default Maven L&F.

I “posted(Advanced Table display using JSP Tags)”:http://www.magpiebrain.com/archives/000095.html a while back about my discovery of the “Display tag Library”:http://displaytag.sourceforge.net/, used to created tables in JSP pages. To recap the tag can handle formatting, automatic export options (Excel, CSV, XML), sorting and grouping with a minimum of fuss. Back then I was impressed just from reading the documentation and from viewing the “on line demos(Live Examples of the Displaytag library)”:http://www.displaytag.org/index.jsp. Now I’m impressed because I just used it to generate a very simple contacts list for our intranet, and it took me about 2 hours to download the taglib, install it, work out how to use it and then create a great looking table with sorting, grouping and CSV export. To be honest, I spent as much time playing with the CSS as anything else.
Next up, I think I’m going to look at a simple way of putting form controls in the table. A “prototype(Display tag library – Editable table implementation)”:http://sourceforge.net/tracker/index.php?func=detail&aid=755192&group_id=73068&atid=536615 based on the Display Tag was built but it seems a little complex, and despite being posted several months ago it doesn’t seem to of been integrated in the code base yet. Hopefully I’ll be able to come up with some simple extensions that don’t require too much coding.

Work is proceeding on my second article on the “Informa API”:http://informa.sourceforge.net/ – I’m currently refactoring the FeedManager class whose use forms the basis of the article. The FeedManager‘s job is to manage multiple feeds, and handle their lazy loading (which will fix a major flaw with the simple code presented in “my first article(Java.net – Using RSS in JSP pages)”:http://today.java.net/pub/a//today/2003/08/08/rss.html). I’m also getting to grips with OPML – support for which was added to Informa as of the 0.4.0 release by Niko Schmuck (Informa’s project manager), and will be adding a method to add channels from an OPML file to the FeedManager itself. All changes will be going back into the Informa code base – expect them to appear in the next release.

The Display tag library is a JSP Taglib that provides the advanced formatting and display of tables. As well as the ability to do simple things like style the data, it can also transform it using decorators, provide automatic searching, paging, grouping and even export to CSV, Excel or XML! I deal daily with tabled data and this taglib will be an absolute godsend. To get a good idea of what the taglib is capable of check the “live examples(JSP Display Tag in action)”:http://www.displaytag.org/displaytag-1.0-b1-examples/index.jsp.
Originally spotted over at “Dion(Dion – JSP Tag Libraries)”:http://blogs.codehaus.org/people/dion/archives/000184.html.