Friday 5 August 2016

How to create and deploy a portlet in liferay7 using liferay IDE and Gradel

New Portlet/Module Using Liferay IDE



To create anew portlet in liferay we first need to install the Blade CLI and then we need to create a new Liferay Workspace. Please go through the above tutorials if you haven't yet installed Blade CLI and created Liferay Workspace.


A new liferay7 portlet/module can be created by clicking upon New-> Liferay Module Project.  Once you clicked upon it you will be presented with the following screen.
Fill up the name of the project in this case My-First-Mvc. Select the desired Project Template, in this case mvcportlet. And click Next.


Liferay7  
On click of next below screen will come up which needs the Controller class name and the package name.
Liferay7
Specify the name of the portlet controller and the package name. If you are not specifying any class then by default it will be creating a class named <PROJECT_NAME><TEMPLATE_NAME> MyFirstMvcmvcportlet  in this case. Package will be taken as com.example. You can specify whatever you want in these two boxes.
The component class name will be considered as the controller of the portlet.


Liferay7
This will create a new portlet in the workspace module folder as shown below
Liferay7
By default the Workspace and the newly created modules are Hierarchical, due to which the newly created portlet is shown inside the LR workspace. To bring out the portlet from the workspace we need choose the FLAT view of project presentation from the explorer view as shown below.
Liferay7
Now we can start the development on this  project . We can see that the required files have been generated by the IDE> It has created the controller, language.properties and JSPs.
MyControllerPortlet -> The controller of the portlet
Language.properties -> Contains the key and values for the portlet.
META-INF -> Resources -> Contains the required JSPs.
bnd.bnd -> Contains the bundle specific information. Like the name of the bundle and the version
build.gradle-> Contains the dependency required for the build of this project. It includes some of the dependencied like
compile group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.0.0"
compile group: "com.liferay.portal", name: "com.liferay.util.taglib", version: "2.0.0"
compile group: "javax.portlet", name: "portlet-api", version: "2.0"
compile group: "javax.servlet", name: "servlet-api", version: "2.5"
compile group: "jstl", name: "jstl", version: "1.2"
compile group: "org.osgi", name: "org.osgi.compendium", version: "5.0.0"
These dependencies allows the JARs to be included in the project. We can add furthers JARs using the dependencies.


How to Deploy the Portlet/Module in Liferay Server -:
To deploy the portlet in liferay7 we need to use the Gradle taskes. We need to open up the Gradle Tasks view. This view will bring up all of the Tasks that can be performed on this particular Workspace or the project.
GOTO -> Windows ->Show View -> Others -> GRADLE -> Gradle Tasks
Liferay7
It will open up the following view. Now to deploy a particular module we need to run the deploy task from the drop down of My-First-Mvc. As shown below


Liferay7
This will deploy the portlet in the liferay server configured in gradel.properties of Liferay workspace. It can be verified from the tomcat logs. The following line will be printed in the liferay liferay logs which will verify that the module has been deployed correctly.
17:46:24,932 INFO  [Refresh Thread: Equinox Container: 0021c311-1157-0016-1ecd-f5121212f1ef][BundleStartStopLogger:35] STARTED my.first.mvc_1.0.0 [481]


This is how you can create and deploy your portlets/modules in liferay7.


j\

0 comments:

Post a Comment

 

Copyright @ 2016 LiferayRevisited.