Thoughts Electrique

Archive for December, 2008

A case against the almighty project document

Saturday, December 20th, 2008

To create good documentation is an art for itself and most often underestimated by us fellow software developers, architects and software project management folks. I won’t go into the detail of what makes a good documentation (in my point of view) in this blog post too deeply (maybe in the future, if you are interested?). Instead I want to point out a negative point which I run into quite frequently: The almighty project document.

(more…)

Manipulating OpenCms XMLContent programatically (some examples)

Friday, December 12th, 2008

Because someone asked on the mailing list and I keep forgetting the respective API calls to manipulate an OpenCms XMLContent programatically.

This is just a raw code dump not a step by step tutorial.

You can also download a ZIP file for importing it into OpenCms. But you have to adjust the paths manually.

(more…)

Use the power of JSP tag files in OpenCms

Friday, December 12th, 2008

Since version 7 OpenCms is a Servlet 2.4 and JSP 2.0 conforming application. In addition to the improved expression language (EL) JSP 2.0 also brings in the possibility of developing custom tags(actions) using JSP rather than writing Java code. This allows for some pretty neat things and enables you to go one step further towards cleaner view code. I’ve used this in one of my last projects extensively to refactor common code like pagers and link generation. For example:

<cms:include file="/system/modules/com.example.ocms.commons/elements/pager">
  <cms:param name="currentPage">
    <c:out value="${model.currentPage}"/>
  </cms:param>
  <cms:param name="pageCount">
    <c:out value="${model.pageCount}"/>
  </cms:param>
</cms:include>

Became:

<wt:pager model="${model}"/>

Not does it only look cleaner and is much more focused, it also decouples your view more from the underlying CMS solution. Of course you could also develop a custom tag library using Java (which I have done a few times) but using a JSP the advantage that code can be changed on the fly and even from a web designer. You can always refactor your JSP taglib into a Java one if you need to do it. There are some limitations of JSP tag files (like you can’t use scriptlets in the body) but they are easy to get around.

But as always: This is no silver bullet. There are problems with tag files which may not be obvious at the first glance.

(more…)

Display RSS Feeds in JSPs with RSS4JSP

Thursday, December 11th, 2008

I recently discovered the freshly released RSS4JSP tag library. Its a wrapper around the mature and widely used Rome RSS library which was developed by Sun and then open sourced. The library allows you to simply display (news) feeds inside your JSP pages.

While it’s certainly a young project, I found it very useful and easy to use. I gave it a try to create the Latest blog posts box on my, OpenCms based, homepage. The box was created during 5 minutes which I think is impressive (given that you have to type the HTML too).

Unfortunately the project does not allow the syndication of multiple feeds into one feed (This is a nice feature of Rome which I used in a recent project) but maybe it will be added in the future (or I will add it myself).

Check it out at sourceforge or visit the authors blog.

Enterprise grade software is an euphemism

Thursday, December 4th, 2008

I recently had to restart a Java webapplication because somehow the JDBC connection to the database server was hanging completely. This reminded me of a sentence a friend of mine told me during the OpenCms Days 2008.

“Enterprise software just means that it’s targeted at customers who can afford the guy who restarts the application server every few hours.”

I had to laugh because while the quote is clearly cynical it has a true core. Especially if you compare languages like Java and PHP it’s true that PHP doesn’t have these kind problems. This is mostly because of the throw-away-the-state nature of PHP. After every served request PHP forgets what it’s done before and has to completely rebuild the working environment at the next request. Java in contrast is able to remember things between requests. Which makes it more powerful but also harder to maintain (more state, more problems). I’m really not sure if I’m buying into this enterprise-thing anymore. Especially if you need scalability you definitely want to keep application state at a minimum and without state you don’t really need those big interconnected clusters of application servers any more.

Here is a nice talk about scalability and serious (speak enterprise) languages I found recently. It’s from Cal Henderson a software development guy at Flickr. It’s really worth watching. Even if you’re not into Python and Django.

(Watch it at: http://www.youtube.com/watch?v=i6Fr65PFqfk&feature=PlayList&p=D415FAF806EC47A1&index=10)