Sunday, January 23, 2011

Liferay Agile JSP development with Maven

If you use Maven for Liferay SDK Plugin development you can get your JSPs changes instantaneously in the browser. This involves two steps:
  1. Create an xml file named for example my-portlet.xml and copy it to the Liferay deploy folder. The content of the file is a single xml node with attribute "docBase" which value must be the target exploded application directory. For example:
  2. You need to make sure when you change your JSPs they are automatically pushed into the target directory. This is the default behaviour in Netbeans. In Eclipse you can play with the Maven plugin for this however there is a fastest way: Use the fileSync eclipse plugin

You might be wondering why you need to use a context file while you don't need it when doing servlet programming.

The answer is that Liferay will manage web applications in specific folders below the temp directory. The folders have a portlet number followed by a dash and then the name of the portlet. Under those folders is where you need to touch JSP files in order for the changes to show up. However the number might change so the folder path is not a constant. Definitely the "/Context@docBase" directive comes in really handy.

No comments: