Thursday, June 30, 2011

Build rich XML-enabled applications with Apache Cocoon 3.0 and Apache Wicket

[See this post in the new blog]

Some articles are already around about Apache Cocoon 3.0, a deep rewrite of an Apache project that is bringing to the community innovative concepts since 1998.

To be honest, the latest release is slowly approaching to a stable level, especially if compared to the wide spread and appreciation that 2.x series used to have - and still has, to a certain extent - all around the world. Consider only the date of this post reporting the official announcement of the initial work: almost three years ago now, normally enough to consider an Open Source project barely death.

Anyway, the user base seems to be wider than (at least, I've) expected, and still messages pass in Apache Cocoon's mailing lists asking for help, considerations, feature requests. Moreover, some blog entries like this and this recently appeared about Apache Cocoon 3.0, showing that there seems to be still room for the "Cocoon way" to Internet applications.

Ok, I might not be completely objective, but I really do believe that there is still nothing around comparable to Apache Cocoon, when it comes to deal with XML content.
An example of this is the Hippo Cocoon Toolkit project aiming to provide an alternative, Apache Cocoon 3.0 based, toolkit for building front-end web sites while relying upon Hippo CMS.

Apache Cocoon 3.0 has a very slimmed-down and targeted nature if compared to its ancestors (especially 2.1), thought for implementing any kind of web interaction, from portals to CRUD applications. But, from the other side, it provides any mean for a smooth integration in almost any environment.

Let's briefly see how simple and extremely powerful can be to build a web application capable of fancy AJAX stuff and, at the same time, strong XML processing.
Start by downloading the source code of the sample web application: as you can see, all you need to run is Apache Maven (2.2.1 or 3.0.3) installed in your workstation; then uncompress, cd and launch
 # mvn clean package jetty:run
Now point your favorite browser to http://localhost:8888/: voilĂ ! You can now see three different kinds of interaction available in this sample web application:
  1. Embed content produced by Cocoon pipelines in Wicket pages (source code: Homepage.java): you can then, for example, place somewhere in your Wicket form a snippet generated by a Cocoon pipeline; note here that Cocoon pipelines are written as pure Java code, no XML;
  2. Use full featured Cocoon pipelines (source code: sitemap.xmap): just empower Cocoon the good old way;
  3. Use full featured Wicket pages (I just grab the source code from the AJAX section of Wicket samples).

Nice, isn't it? ;-)

All this above can be considered as a very first insight in the many facets of Apache Cocoon 3.0: take a tour of its features to have a better idea; did I tell you, for example, about its RESTful attitude?

4 comments:

  1. Hi Francesco, one little remark. I had to add the maven-compiler-plugin to the pom in order to run your demo.

    Kind regards,
    Robby Pelssers

    ReplyDelete
  2. Hi Robby,
    which maven version / platform are you running on?

    ReplyDelete
  3. I had to add a maven-compiler-plugin and set the source code to 1.5 manually. Other than that it works like a charm, great demo!

    ReplyDelete
  4. @Robby and @Huib: thank you very much for your feedback; I guess this issue was due to the fact that I did not test the build with Maven 2 (only Maven 3).

    Anyway, I've updated the source code attached to the post.

    ReplyDelete