Wednesday, November 24, 2010

Simple Struts Portlet

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>...

Liferay testing tools

1. jUnit2. selenium3. jMeter4. Grin...

Spring Portlet

Step 1:create a dummy JSP portlet to begin with by using the following commandcreate.bat weather "Weather Spring Portlet"================================================================Step 2: create a folder "context" under "/docroot/WEB-INF"create file "weather-portlet.xml" under "context"<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "../../dtd/spring-beans.dtd"><beans><bean id="weatherService" class="com.sample.weather.WeatherServiceImpl" /> <bean id="weatherController" class="com.sample.weather.WeatherController"> <property name="weatherService" ref="weatherService" /> </bean> <bean class="org.springframework.web.portlet.handler.PortletModeHandlerMapping"> <property...

Liferay-clustering

Running Liferay in a clustered environment consists of 6 steps.1. Preparations and getting things ready.2. Connecting to a remote MySQL database.3. Running 2 or More "IDENTICAL" Liferay tomcat instances on 2 Or more physical machines.4. Making one machine as "Apache Web Server"5. Connecting apache with tomcat using apache module "mod_jk"6. Configuring mod_jk for clustering for both load-balancing and fail-over.7. Verifying whether clustering is working fine.=================================================================================1. Preparations and getting things ready.Select 4 physical machines (servers) in your LAN network. Each should have an internal IP address.Just ping between the 4 machines and confirm that the pinging is successful.Make sure none of the machines have fire wall...

Programmatically import LAR file into Liferay.

public static void addDefaultLayoutsByLAR( long userId, long groupId, boolean privateLayout, File larFile) throws PortalException, SystemException { Map parameterMap = new HashMap(); parameterMap.put( PortletDataHandlerKeys.PERMISSIONS, new String[] {Boolean.TRUE.toString()}); parameterMap.put( PortletDataHandlerKeys.PORTLET_DATA, new String[] {Boolean.TRUE.toString()}); parameterMap.put( PortletDataHandlerKeys.PORTLET_DATA_CONTROL_DEFAULT, new String[] {Boolean.TRUE.toString()}); parameterMap.put( PortletDataHandlerKeys.PORTLET_SETUP,...

Creating a new Theme

In the $PLUGINS_SDK/themes folder run: ant -Dtheme.name=newtheme -Dtheme.display.name="My New Theme" create"newtheme" will be the theme name we would like to give."My New Theme" will the display name of our theme.Navigate to the newly created $PLUGINS_SDK/themes/newtheme/_diffs and add some customizations to the default theme.After this, In the $PLUGINS_SDK/themes folder run: ant warThe war file of our theme will be created in the $PLUGINS_SDK/themes/dist .Now deploy this war file.You can go to your deploy (webapps) directory and see the new theme folder being created there.Once your theme has been deployed, and you're ready to modify the CSS, use the custom.css file to change and override the default styling, leaving all of the other CSS files alone. You can modify any...

Import the lar file for the guest community.

Enable the below property in portal-ext.properties to import the lar file for the guest community. # # Specify a LAR file that can be used to create the guest public layouts. # If this property is set, the previous layout properties will be ignored. # default.guest.public.layouts.lar=${liferay.home}/deploy/default_guest_public....

Inter Portlet Communictaion For Session Attributes

If we set any value in session it will be available until session available.Include Following Line in liferay-portlet.xml:<private-session-attributes>false</private-session-attributes>Create session attribute in any file:PortletSession ps = req.getPortletSession();ps.setAttribute(key, value, PortletSession.APPLICATION_SCOPE);Example:ps.setAttribute("SAMPLE_ATTRIBUTE", "sample", PortletSession.APPLICATION_SCOPE);Access in other Portlet File:String name = ps.getAttribute("SAMPLE_ATTRIBUTE", PortletSession.APPLICATION_SCOPE);Now name contains samp...

SignOut Message in .vm File

Step: 1Add the below lines in LogoutAction.javaafter session.invalidate();HttpSession logoutSession = request.getSession();logoutSession.setAttribute("logoutSession", logoutSession);Step: 2create EXTServicePreAction.java under (com.liferay.portal.events.EXTServicePreAction.java )EXTServicePreAction.javapackage com.liferay.portal.events;import java.util.HashMap;import java.util.Map;import java.util.logging.Level;import java.util.logging.Logger;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import com.liferay.portal.kernel.events.Action;import com.liferay.portal.kernel.events.ActionException;import com.liferay.portal.kernel.util.Validator;import com.liferay.portal.util.WebKeys;public class EXTServicePreAction extends...

Installing Liferay 5.2.3 on Existing Apache Tomcat 6.0.24

1. Download and install Apache Tomcat 6.0.24 into your preferred directory.2. Download and install JDK 5 . Set an environment variable called %JAVA_HOME% (in Windows) or $JAVA_HOME (in Linux/UNIX) to point to your JDK directory.3. Create and edit $TOMCAT_HOME/conf/Catalina/localhost/ROOT.xml to set up the portal web application. <Context path="" debug="0" reloadable="true" cookies="true" crossContext="false" privileged="false" />4. Download liferay-portal-5.2.3.war.5. Download Liferay's Portal 5.2.3 Dependencies. 5.1. Create a $TOMCAT_HOME/lib/ext directory and unzip the dependencies ZIP in there.6. Edit $TOMCAT_HOME/conf/catalina.properties. common.loader= ${catalina.home}/common/classes,\ ...\ ${catalina.home}/common/lib/ext/*.jar7. Make sure your database server is...

Inter Portlet Communication (IPC) for Portlets on Different Page

Use the below code for Inter Portlet Communication (IPC) for Portlets on Different Page:-String plidName = "Sample_WAR_Sampleportlet";long plidForward = getPortletId(plidName);PortletURL url = new PortletURLImpl(request,plidName, plidForward, PortletRequest.ACTION_PHASE);--------------------------------------------------------------------------------- public static long getPortletId(String portletId) { PortletPreferences prfs = null; try { DetachedCriteria dCriteria = DetachedCriteria .forClass(PortletPreferences.class); dCriteria.add(Restrictions.eq("portletId", portletId)); DynamicQuery dynamicQuery = new DynamicQueryImpl(dCriteria); ...

Pages 91234 »

Share & Enjoy

Twitter Delicious Facebook Digg Stumbleupon Favorites More