Sunday, 17 March 2013

Spring MVC Portlet in Liferay

Liferay is one of the portal frameworks based on java. You can create portlets in Liferay using Spring MVC framework. This post may give you the answer of your one question "How to create a portlet in Liferay using Spring MVC ? ".  You can setup Liferay from here

Let's think about a user interface where search contents can be added into a search repository. Let's play with Liferay and Spring MVC Portlet to provide this user interface and feature. We can have a portlet named 'Add Search Content Portlet' as a user interface to add the search contents into a search repository.

Add Search Content Portlet: This portlet can have three fields to add the search contents: ID, Title and Description. If you see in below screen shots, I have added three hotel names as search content in terms of ID (hotel id), Title (hotel name) and Description (about hotel). 


Steps for Portlet Implementation  

To implement a portlet in Liferay using Spring MVC you need to follow below steps. Source code can be referred from document. 

1. Configuring Spring context file, this is a core configuration in applicationContext.xml file where you need to define the   message bundle, view resolver, portlet resolver etc.  [refer (a) in document]

2. Adding configuration in portlet.xml, liferay-display.xml and liferay-portlet.xml. These are the liferay specific configuration files, where you need to define the portlet name and   display name, portlet specific configuration file like addSearchContent.xml etc. [refer (b), (c) and (d) in document]

3. Configuring portlet specific configuration file like addSearchContent.xml, where you define the controller bean which serves the request for this  portlet. [refer (e) in document]

4. Creating java value objects, these objects are used to map JSP filed values into java object. [refer (f) in document]

5. Defining the controller class, this is a controller class where actual request is served for this portlet. [refer (g) in document]

6. Creating JSP, where portlet UI is defined. [refer (h) in document]

After creating all above source files you can build your application and then deploy on application server. Access your Liferay server, add a test page and add your new portlet on test page. You can refer this link to add new portlet into your page.

                                  
Refer below links for more detail:


No comments:

Post a Comment