Thursday, October 16, 2008

Struts Portlet with action class.

After creating simple struts portlet, update the below 2 xml files:



1. struts-config.xml


<action path="/ext/library/add_book" type="com.ext.portlet.library.action.AddBookAction">

<forward name="portlet.ext.library.view" path="portlet.ext.library.view" />

<forward name="portlet.ext.library.error" path="portlet.ext.library.error" />

<forward name="portlet.ext.library.success" path="portlet.ext.library.success" />

</action>



2.tiles-defs.xml


<definition name="portlet.ext.library.error" extends="portlet.ext.library">

<put name="portlet_content" value="/portlet/ext/library/error.jsp" />

</definition>



<definition name="portlet.ext.library.success" extends="portlet.ext.library">

<put name="portlet_content" value="/portlet/ext/library/success.jsp" />

</definition>
=============================
And create these JSP files:
(location : /ext/ext-web/docroot/html/portlet/ext/library)

init.jsp


(remove the text line added earlier)

<%@ include file="/html/common/init.jsp" %>


view.jsp


<%@ include file="/html/portlet/ext/library/init.jsp" %>

<br/>

Add a book entry to the Library:

<br/><br/>

<form action="<portlet:actionURL windowState="<%= WindowState.MAXIMIZED.toString() %>">

<portlet:param name="struts_action" value="/ext/library/add_book" />

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

Book Title:

<input name="<portlet:namespace />book_title" size="20" type="text" value=""><br/><br/>

<input type="button" value="Submit" onClick="submitForm(document.<portlet:namespace />fm);">

</form>

<br/>

success.jsp

<%@ include file="/html/portlet/ext/library/init.jsp" %>

<%

String bookTitle = request.getParameter("book_title");

%>

<table align="center" cellspacing="10" cellpadding="3">

<tr>

<td style="font-weight:bold">Book Title: </td>

<td><%= bookTitle %></td>

</tr>


error.jsp


<%@ include file="/html/portlet/ext/library/init.jsp" %>

<font color="red">Error in page...</font>
=============================

Create this Java file:


AddBookAction.java

(location: ext/ext-ejb/src/com/ext/portlet/library/action/AddBookAction.java)



package com.ext.portlet.library.action;

import javax.portlet.ActionRequest;

import javax.portlet.ActionResponse;

import javax.portlet.PortletConfig;

import javax.portlet.RenderRequest;

import javax.portlet.RenderResponse;



import org.apache.struts.action.ActionForm;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;



import com.liferay.portal.struts.PortletAction;

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



public class AddBookAction extends PortletAction {



public void processAction(

ActionMapping mapping, ActionForm form, PortletConfig config,

ActionRequest req, ActionResponse res)

throws Exception {



String bookTitle = req.getParameter("book_title");



if (Validator.isNull(bookTitle)) {

setForward(req, "portlet.ext.library.error");

} else {

setForward(req, "portlet.ext.library.success");

}

}



public ActionForward render(ActionMapping mapping, ActionForm form,

PortletConfig config, RenderRequest req, RenderResponse res)

throws Exception {

if (getForward(req) != null && !getForward(req).equals("")) {

return mapping.findForward(getForward(req));

} else {

return mapping.findForward("portlet.ext.library.view");

}

}

}

Now you can get, simple portlet with struts acton.

- Gnaniyar Zubair

Friday, October 10, 2008

Writing a Simple JSPPortlet - ERROR

portlet-ext.xml

This below code will accept only in old version of liferay:

<portlet-class>com.liferay.portlet.JSPPortlet</portlet-class>

In Liferay 5.1, we have to use this portlet class for simple JSP portlet:

<portlet-class> com.liferay.util.bridges.jsp.JSPPortlet </portlet-class>

- Gnaniyar Zubair

Thursday, October 9, 2008

Create Simple Struts Portlet

These are the steps for creating simple Struts Portlet.

[the xml files are located under "ext/ext-web/docroot/WEB-INF"]


1.1. portlet-ext.xml



<portlet>

<portlet-name>EXT_3</portlet-name>

<display-name>Library Portlet</display-name>

<portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>

<init-param>

<name>view-action</name>

<value>/ext/library/view</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>

<security-role-ref>

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

</security-role-ref>

</portlet>



1.2. liferay-portlet-ext.xml


<portlet>

<portlet-name>EXT_3</portlet-name>

<struts-path>ext/library</struts-path>

<use-default-template>false</use-default-template>

</portlet>



1.3. struts-config.xml



<action path="/ext/library/view" forward="portlet.ext.library.view" />



1.4. tiles-defs.xml


<definition name="portlet.ext.library" extends="portlet" />

<definition name="portlet.ext.library.view" extends="portlet.ext.library">

<put name="portlet_content" value="/portlet/ext/library/view.jsp" />

</definition>





(create the following two jsp files under "/ext/ext-web/docroot/html/portlet/ext/library")


1.5. init.jsp



<%@ include file="/html/common/init.jsp" %>

<p>Add commonly used variables and declarations here!</p>



1.6. view.jsp


<%@ include file="/html/portlet/ext/library/init.jsp" %>

Simple Struts Portlet!



1.7 Language-ext.properties



javax.portlet.title.EXT_3=Library Portlet


- Gnaniyar Zubair

Saturday, September 27, 2008

Create Basic JSP Portlet

To create simple JSP portlet, you have to modify these files:


Step I :

[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
5. Language-ext.properties


Step II:

ant deploy

===========================

Step I :

1.1. portlet-ext.xml

<portlet>

<portlet-name>EXT_2</portlet-name>

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

<portlet-class>com.liferay.portlet.JSPPortlet</portlet-class>

<init-param>

<name>view-jsp</name>

<value>/portlet/ext/jsp_portlet/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>

<security-role-ref>

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

</security-role-ref>

</portlet>


1.2.liferay-portlet-ext.xml
<portlet>

<portlet-name>EXT_2</portlet-name>

</portlet>


1.3. liferay-display.xml

<category name="category.example">

<portlet id="EXT_2"></portlet>

</category>


1.4 view.jsp
(create this file under "ext/ext-web/docroot/html/portlet/ext/jsp_portlet"
and enter the below contents)


Welcome to simple Basic JSP Portlet


1.5 Language-ext.properties


javax.portlet.title.EXT_2=JSP Portlet


Step II :

Go to inside the ext in terminal then give ant deploy

ext>ant deploy


- Gnaniyar Zubair

jQuery datepicker in Liferay

This is date picker coding:

create any simple jsp portlet and in view.jsp apply this coding and try it out.


textbox id = basics

input type="textbox" id="basics" size="10" value="click here"

in script write this code :

jQuery('#basics').datepicker();





-Gnaniyar Zubair

Hide the dock(welcome tab) for Guests.

If you want to hide the welcome tab (top rightside) which is called dock, you can use one of these code in portal_normal.vm file.

Firest Method:

#if($themeDisplay.isSignedIn())#parse ("$full_templates_path/dock.vm")#end

Second Method:


#if(!$user.isDefaultUser())#parse ("$full_templates_path/dock.vm")#end

- Gnaniyar Zubair

Tuesday, January 15, 2008

LIFERAY INSTALLATION - REVIEW

To setup Liferay in your System, you have to follow these 4 steps:

Step 1 :

Liferay Installation 1 : Java & Liferay

http://lifebyliferay.blogspot.com/2008/01/liferay-installation-java-liferay.html

Step 2 :

Liferay Installation 2. Jikes,Ant & Liferay Portal Source

http://lifebyliferay.blogspot.com/2008/01/liferay-installation-2-jikesant-liferay.html

Step 3 :

Liferay Installation - 3. EXT Environment

http://lifebyliferay.blogspot.com/2008/01/liferay-installation-3-ext-environment.html

Step 4 :

Liferay Installation 4 : Database Connection

http://lifebyliferay.blogspot.com/2008/01/liferay-installation-4-database.html

- Gnaniyar