A Portlet is a Web component that processes requests and generates dynamic content.
A portlet is a reusable building block for easily publishing information and applications.
Here i am giving the step by step code snippets for creating simple Jsp portlet in Liferay Enviroinment.
To create simple JSP portlet , We need atleast 3 xml files and 1 jsp file.
[the xml files are located under "ext/ext-web/docroot/WEB-INF"]
1. portlet-ext.xml
2. liferay-portlet-ext.xml
3. liferay-display.xml
4. view.jsp
I . Development
In this xml file, we have to define portlet name and portlet class ..etc…
1.portlet-ext.xml (ext/ext-web/docroot/WEB-INF)
<portlet>
<portlet-name>MYPORTLET</portlet-name>
<display-name>My Portlet</display-name>
<portlet-class>com.liferay.util.bridges.jsp.JSPPortlet</portlet-class><init-param>
<name>view-jsp</name>
<value>/html/testing/myportlet/view.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
</portlet>
2. liferay-portlet-ext.xml (ext/ext-web/docroot/WEB-INF)
We should register that portlet in liferay using this xml file.
<liferay-portlet-app>
//register portlet in liferay
<portlet>
<portlet-name>MYPORTLET</portlet-name>
</portlet>
</liferay-portlet-app>
3. liferay-display.xml (ext/ext-web/docroot/WEB-INF)
this xml file defines Under which category our portlet should be displayed
<display>
// under which category our portlet shoud display in Add Content…
<category name=”category.myportlet”>
<portlet id=”MYPORTLET“></portlet>
</category></display>
4. view.jsp
(create this file under “ext/ext-web/docroot/html/testing/myportlet” )
<h2> Welcome to my first Jsp portlet </h2>
II . Deploy :
Give “ant deploy“ inside ext or ext-web. Start the server and make sure that your portlet is created.
your portlet title will disply like this: javax.portlet.title.MYPORTLET
go to ext/ext-impl/src/content/language-ext.properties file
add this entry:
javax.portlet.title.MYPORTLET = MY JSP PORTLET
then again ant deploy and start the server.
Now, You have sucessfully created Jsp Portlet.
Tags: Liferay, Jsp Portlet
June 29, 2009 at 6:37 am |
[...] Share your knowledge Just another WordPress.com weblog « Create JSP Portlet in Liferay 5.2.X [...]