Tuesday, June 14, 2011

Understanding Directory Structure and Various Files in Liferay Portlet Plugin

Share |
<b>Understanding directory structure and various files of Portlet Project </b>
A portlet project is made up at a minimum of three components:
1. Java Source
2. Configuration files
3. Client-side files (*.jsp, *.css, *.js, graphics, etc.)
These files are stored in a standard directory structure which looks
like the following:
                             /src/ (not created by default)
New portlets are configured by default to use the <b>MVCPortlet</b> framework, which uses separate JSPs for each page in the portlet, and for each of the three portlet modes: view, edit, and help. The <b>Java Source</b> is stored in the <b>docroot/WEB-INF/src</b> folder. The <b>Configuration Files</b> are stored in the <b>docroot/WEB-INF</b> folder. The standard JSR-286 portlet configuration file  

portlet.xml can be found in this folder, as well as three Liferay specific portlet configuration files are located in this folder. The Liferay specific configuration files are completely optional, but are important if your portlets are going to be deployed on a Liferay Portal server.

liferay-display.xml: This file describes the category in which the portlet should appear under in the Add menu.

liferay-portlet.xml: This file describes some optional Liferay-specific enhancements for JSR-286 portlets which user can configure when that are installed on a Liferay Portal server. For example, you can set whether a portlet is instanceable or not, which means that you can place more than one instance on a page, and each portlet will have its own separate data. Please see the DTD for this file for further details, as there are too many settings to list here. The DTD may be found in the definitions folder in the Liferay source code.

liferay-plugin-package.properties: This file describes the plugin to Liferay's hot deployer. One of the things that can be configured in this file is dependency .jars. If a portlet plugin has dependencies on particular .jar files that already come with Liferay, you can specify them in this file and the hot deployer will modify the .war file on deployment so that those .jars are on the class path.

Client Side Files are the .jsp, .css, and JavaScript files that you write to implement your portlet's user interface. These files should go in the docroot folder somewhere—either in the root of the folder or in a folder structure of their own. Remember that with portlets you are only dealing with a portion of the HTML document that is getting returned to the browser. Any HTML code you have in your client side files should be free of global tags such as <html> or <head>. Additionally, all CSS classes and element IDs must be namespaced with the portlet ID to prevent conflicts with other portlets or multiple instance of the same portlet.

Share |

No comments:

Post a Comment