Liferay

Add custom portlet into control panel in Liferay 7.2

Bhargav Vaghasiya
Bhargav VaghasiyaJun 23, 2020
Add custom portlet into control panel in Liferay 7.2

Introduction

Liferay provided many customizations under the control panel. We can add our own portlet in the Liferay control panel. Here you will learn about how we can add a custom portlet into the Liferay control panel.

Prerequisites

  • Java
  • Liferay portal 7/7.x

Environment Requirement

  • JDK 8
  • Eclipse
  • Liferay Portal

Follow below step for add portlet in control panel

1) Create MVC portlet

  1. Go to Liferay workspace project  modules  new.
  2. Select other  Liferay  Liferay Module Project and click on “Next”.
  3. Enter the project name.
  4. Select “Project Template Name” as “mvc-portlet” and click on “Next”.
  5. Enter a Package name and click on “Finish”. The necessary file structure for the MVC module will get created
Blog Image

Add the below property in the Portlet class

1// StudentPortlet.java
2package com.ignek.portal.student.portlet;
3
4@Component(
5    immediate = true,
6    property = {
7        "com.liferay.portlet.display-category=category.hidden",
8        "com.liferay.portlet.instanceable=true",
9        "javax.portlet.display-name=Student Portlet",
10        "javax.portlet.init-param.template-path=/",
11        "javax.portlet.init-param.view-template=/view.jsp",
12        "javax.portlet.name=" + StudentPortletKeys.PORTLET_ID,
13        "javax.portlet.resource-bundle=content.Language",
14        "javax.portlet.security-role-ref=power-user,user",
15    },
16    service = Portlet.class
17)
18public class StudentPortlet extends MVCPortlet {
19
20}

2) Implement your constants class

Add below code in your constants class.

1// StudentPortletKeys.java
2package com.ignek.portal.student.constants;
3
4public class StudentPortletKeys {
5
6	public static final String PORTLET_ID = "com_ignek_portal_student_portlet_StudentPortlet";
7
8}

4) Create your panel app component class

This class must extend the BasePanelApp Class and declare it as a service using service = PanelApp.class.

1//  StudentPanelApp.java
2package com.ignek.portal.student.portlet;
3
4@Component(
5    immediate = true,
6    property = {
7        "panel.app.order:Integer=0",
8        "panel.category.key=" + PanelCategoryKeys.CONTROL_PANEL_USERS
9    },
10
11    service = PanelApp.class)
12
13public class StudentPanelApp extends BasePanelApp {
14
15    @Override
16    public String getPortletId() {
17        return StudentPortletKeys.PORTLET_ID;
18    }
19    @Override
20    @Reference(target = "(javax.portlet.name=" + StudentPortletKeys.PORTLET_ID + ")", unbind = "-")
21    public void setPortlet(Portlet portlet) {
22        super.setPortlet(portlet);
23    }
24}

Lets understand following:

panel.category.key” defines the category which is “control_panel.users” in our case. So our Student portlet will be added under “Users” section in control panel.

panel.app.order” defines the portlet position in the portlet list under “Users” section in control panel.

Now your necessary file structure will get created as below.

Blog Image

5) Deploy your module and you can see your module in the Liferay control panel

Blog Image

© 2026 IGNEK. All rights reserved.

Ignek on LinkedInIgnek on InstagramIgnek on FacebookIgnek on YouTubeIgnek on X