Pages

Friday, 23 May 2014

portal.properties: Load properties from external file

Hi,
        This topic is simple but mandatory for developer to go through with it since this comes with best practices.


1. Include "com.liferay.util.portlet.PortletProps" package into your jsp or in java


2. Make a properties file & put into source folder of your portlet named as portal.properties.


3. put some entries in that file like
                 my_custom_message=this is from your external properties files

4. Now you can fetch the properties by the following way:


  • In Jsp

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
               <portlet:defineObjects />
               <%@ page import="com.liferay.util.portlet.PortletProps" %>
               <%= PortletProps.get("messages.per.page") %>

                



  • In  Java
import com.liferay.mail.util.PortletProps;

PortletProps.get("messages.per.page");



Wednesday, 14 May 2014

Display profile pictures of all users in liferay?

Hi,

 Today I am going to show you how you can get Profile picture or Portrait of all users belonging to particular community or organization. Yet the problem sounds little bit easy but this post will save your time to make it correct in single attempt.


Problem :  I want to show a  slider to end user in which logo of all my clients will comes. It will look nice since it is dynamically generated means whenever a user will register & admin has assigned Client(Vendor) role to that particular  user.

Than his/her profile pic or in case of company a logo will automatically append in the existing slider....

Solution:

 1.  Make a simple portlet.

 2.  Put the following code in to your view.jsp


<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ page import="com.liferay.portal.service.UserLocalServiceUtil"%>
<%@ page import="com.liferay.portal.model.User"%><%@ page import="java.util.List"%><portlet:defineObjects /><h1> Our Partners</h1><marquee behavior="scroll" direction="left"><%int i= UserLocalServiceUtil.getUsersCount();List<User> user =UserLocalServiceUtil.getUsers(0, i);String imgsrc="/image/user_male_portrait?img_id=";for(int j=1;j<i;j++){%><img src="<%=imgsrc+user.get(j).getPortraitId() %>"/>&#160; &#160; &#160; &#160;<%} %></marquee>


3. Deploy this portlet on liferay server.

4. Put ity on desire page.

5. It will show a slider(marquee) with profile pic of all users.6. Here is the output









Please keep sharing.... what you learn.


:)


Thursday, 6 February 2014

Liferay Database Migration

Hi friends,
              From liferay 6.1 it becomes very easy to migrate database of liferay from  its default hqDB to your desired database life Mysql, MSSQl, PostSql from control panel. In this post I will tell you how to achieve this both from control panel & by using portal-ext.properties file.



From Control panel.

1. login as admin in your liferay portal.
2.Go to control panel.
3. Chosse  from right hand panel--->server-server administrator--->Data Migration tab
4. be sure you have connector .jar for your particular jar. Mysql.jar is already placed in liferay portal so no need to do any staff.
put driver class as--->com.mysql.jdbc.Driver
JDBC url--->jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
user-->username of lportal
password-->password of database
than click on execute.


that it the portal will restart by its own & migrate all data in your database.


From portal-ext.properties file.

1.Open location
liferay root->tomcat-->webapp-->root-->WEB-INF-->classes
2.create a new file portal-ext.properties here
and paste this content as it as for my sql.


jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=root
jdbc.default.password=password




above explaination

first line is used for driver class.

second line is used for giving the url where database server is running here i have used localhost after that database name which you want to use for migration.(lportal in my case)

third line used for username of database which have all permissions.

fourth line contains password of that user.


after that save this file & restart the liferay server & you will see the tables in your own database.

please download the portal-ext.properties file from here if you have any trouble.





Monday, 23 September 2013

Liferay Installation and Download

Liferay Installation & Download:

First of all thanks & congratulation for learning Liferay. Welcome to the new world of open wing to give you opportunity to fly in the field of development.

Let's start:



  • You can download a free community edition of Liferay 6.x from  http://www.liferay.com. or follow http://sourceforge.net/projects/lportal/files/Liferay%20Portal/6.1.1%20GA2/liferay-portal-tomcat-6.1.1-ce-ga2-20120731132656558.zip/download

  • There are lots of options I personally recommended you to start with tomcat bundle. It is a zip folder. download it & extract it any where.

  • Goto Liferay folder-->Tomact-->bin-->startup.bat(for windows) or startup.sh(for linux).

  • Just it in your default browser you will see your first liferay screen.
Yepppiii  give your response in case of any difficulty.