Thursday, May 10, 2007

Portlet Book free chapter Review

SourceBeat has made a chapter of their Java Portlet 101 book available for free on TSS which is a good thing for anyone who wants to start using Portlets. This chapter explains how to move your rendering code from the portlet Java class to a JSP or Servlet using a request dispatcher.

Sunil Patil, the book's author strictly follows the JSR-168 specification, so even though his sample is deployed on Pluto, the exact same code would work on JBoss Portal.

The example he's using consist of a hello world kind of application where some text is defined in the Edit mode of the portlet, text which is then displayed in the View mode. The two modes are rendered using a JSP file first, the application is then converted to use a Servlet for the Edit mode. From what is said in this free chapter the exact same example was used earlier in the book without using any request dispatching at all. It seems like an easy incremental path to follow for portlet developer beginners who knows about JSPs and Servlets.

Using JSPs leads the author to explain the portlet tag library and the implicit objects defined by the portlet spec. This part actually doesn't provide much added value above the reading the spec itself but it's always good to have everything at a single place. It's mainly a short version of the PLT 22. Portlet Tag Library chapter.

The subsequent part, titled "Additional ways of including Servlet/JSP content" is actually something that can be interesting for many. It shows a quite common use case of file uploading within a portlet. Patil's using the Apache Commons FileUpload library and its PortletFileUpload class to do so. This is worth checking out if you want to implement portlets supporting file upload and you don't know how to do so.

Finally, the last part is also important to read when you start writing portlets, as it reminds you that you need to strip out some of your HTML since the portlet specification mandates that you provide markup fragments. He's also mentionning the fact that the spec defines CSS styles, which is a good practice to follow when developing portlets.

I only read that chapter of the book unfortunately (if the publisher read this, please send to the portal team a free paper version for a full review ;) ) but looking at the table of content and based on this chapter, it looks like a good overview of the spec itself with samples (the real added value of this book in my opinion) and is not going into any portal vendor specific details.

Highly recommended for beginners who want to assimilate the JSR-168 spec.