Tuesday, 20 December 2016

Create MVC Portlet in Liferay 7 using LiferayIDE

Liferay 7 has adopted OSGI standards.In OSGI everything we create is a module.For more information on OSGI visit my previous blog on OSGI.
  • In this blog I will explain how to create mvc portlet module using Liferay IDE.For information on setup and installing liferay portal (click here).




Create MVC Module using Liferay IDE.


GoTo New→File click on Liferay Module Project.


  • Enter Project Name and select mvcportlet as project template.
  • Click Next and enter component class name and package name then click on finished.




Generated module will be inside module folder of liferay workspace.

Generated Portlet Class

  • Based on input provided generated portlet class is 


ProductRegistrationPortlet.java


package com.liferay.product.portlet;


import com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet;


import javax.portlet.Portlet;


import org.osgi.service.component.annotations.Component;


@Component(

immediate = true,
property = {
"com.liferay.portlet.display-category=category.sample",
"com.liferay.portlet.instanceable=true",
"javax.portlet.display-name=ProductRegistration Portlet",
"javax.portlet.init-param.template-path=/",
"javax.portlet.init-param.view-template=/view.jsp",
"javax.portlet.resource-bundle=content.Language",
"javax.portlet.security-role-ref=power-user,user"
},
service = Portlet.class
)
public class ProductRegistrationPortlet extends MVCPortlet {

}

  • Here property{

          
         }
tag is used to specify properties that are previously specified in portlet.xml and  liferay-portlet.xml

  • For more detail on mapping of portlet XML descriptor values to OSGi service properties click here.
  • Now we can have to build and deploy generated mvc portlet using gradle tasks as shown in fig.



  • Click on build this will generate jar file of porltet module.On clicking deploy this jar will be deployed and your portlet will be available.
  • Note you must have to set liferay.workspace.home.dir and liferay.workspace.modules.default.repository.enabled     properties in gradle.properties (for more information click here)
Other Useful Post 

CRUD In Liferay DXP Using AJAX jQuery

For Spring boot,Spring microservices,Spring MVC,Spring Batch,Hibernate please refer 

For Java - Java 8 please refer Java Tutorial












2 comments:

  1. Muy interesante! Gracias por la info.

    Si te animas haz un post con IPC entre OSGI Portlets modules, con eventos o paso de parĂ¡metros entre portlets.

    ReplyDelete
    Replies
    1. Thanks you..Your comment provides motivation to write new blogs on LiferayDXP. And surely my future post will include IPC in LiferayDXP.

      Delete