Liferay JSP Portlet Development


Liferay JSP Portlet Development

[portlet-ext.xml, liferay-portlet-ext.xml, liferay-display.xml — placed under .. ”  ext/ext-web/docroot/WEB-INF  “


  1. create portlet entry in “portlet-ext.xml”

<portlet>

<portlet-name>JSPPortlet</portlet-name>

<display-name>Simple JSP Portlet</display-name>

<portlet-class>com.ext.portlet.jspportlet.SimpleJSPPortlet</portlet-class>

<expiration-cache>0</expiration-cache>

<init-param>

<name>view-jsp</name>

<value>/portlet/ext/library/view.jsp</value>

</init-param>

<supports>

<mime-type>text/html</mime-type>

</supports>

<portlet-info>

<title>Simple JSP Portlet</title>

<short-title>Simple JSP Portlet</short-title>

<keywords>Simple JSP Portlet</keywords>

</portlet-info>

<security-role-ref>

<role-name>guest</role-name>

</security-role-ref>

<security-role-ref>

<role-name>power-user</role-name>

</security-role-ref>

<security-role-ref>

<role-name>user</role-name>

</security-role-ref>

</portlet>

2.Create liferay specific portlet entry in “liferay-portlet-ext.xml”

<portlet>

<portlet-name>JSPPortlet</portlet-name>

</portlet>

3. create a JSP file named view.jsp inside “/portlet/ext/library/”

<H1> Some Text

4. Create package for JSP portlet class

com.ext.portlet.jspportlet

Create a “Class” SimpleJSPPortlet in the created package

package com.ext.portlet.jspportlet;

import com.liferay.portal.kernel.util.ContentTypes;

import com.liferay.portal.kernel.util.ReleaseInfo;

import java.io.IOException;

import java.io.PrintWriter;

import javax.portlet.ActionRequest;

import javax.portlet.ActionResponse;

import javax.portlet.GenericPortlet;

import javax.portlet.RenderRequest;

import javax.portlet.RenderResponse;

public class SimpleJSPPortlet extends GenericPortlet {

public void processAction(

ActionRequest actionRequest, ActionResponse actionResponse) {

}

public void doView(

RenderRequest renderRequest, RenderResponse renderResponse)

throws IOException {

renderResponse.setContentType(ContentTypes.TEXT_HTML_UTF8);

PrintWriter writer = renderResponse.getWriter();

writer.print(“Simple Liferay Portal 5.2.1 JSP Portlet “);

}

}

5.Create Categoryadd add this portlet under the new one

Open Language-ext.properties iiinside directory “/ext/ext-impl/src/content”

category.extworks=My Works

add this entry to liferay-display.xml

<category name=“category.extworks”>

<portlet id=“JSPPortlet” />

</category>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s