Published using Google Docs
LIFERAY-TUTORIAL-myhelloworldportlet.docx
Updated automatically every 5 minutes

Liferay 6.1 Tutorial - MyHelloWorld Portlet
http://notarazi.blogspot.com


MyHelloWorldPortlet

1.Create new plugin project

2.Choose portlet framework

3. Create portlet class.

4. Specify porlet deployment descriptor details 1.

5. Specify porlet deployment descriptor details 2.

6. Specify modifiers, interfaces, and method stubs to generate Portlet class.

7. Source Code

file: MyHelloWorld.Portlet.java

file: docroot/html/edit.jsp

file: docroot/html/view.jsp

1.Create new plugin project


2.Choose portlet framework

3. Create portlet class.


4. Specify porlet deployment descriptor details 1.


5. Specify porlet deployment descriptor details 2.

6. Specify modifiers, interfaces, and method stubs to generate Portlet class.

7. Source Code

file: MyHelloWorld.Portlet.java


public void processAction(

               ActionRequest actionRequest, ActionResponse actionResponse)

           throws IOException, PortletException {

        

         String name = actionRequest.getParameter("name");

        

         PortletPreferences prefs = actionRequest.getPreferences();

        

         prefs.setValue("NAME", name);

         prefs.store();

        

         actionResponse.setPortletMode(PortletMode.VIEW);

           

           /**super.processAction(actionRequest, actionResponse); */

        

        }

file: docroot/html/edit.jsp


<!-- This is the <b>MyHelloWorldPortlet</b> portlet in Edit mode. -->

<form action="<portlet:actionURL/>" method="post" name="<portlet:namespace />fm">

<label for="name">Name :</label>

<input name="<portlet:namespace />name" type="text" />

<br /><br />

<input type="submit" />

</form>

file: docroot/html/view.jsp


<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<portlet:defineObjects />

<!--  This is the <b>MyHelloWorldPortlet</b> portlet in View mode. -->

<% String name = (String)request.getAttribute("ATTRIBUTE_NAME");

%>

<p>This is the Hello World Portlet</p>

<p>Hello <%= name %>! </p>