Free Online Courses for Software Developers - MrBool
× Please, log in to give us a feedback. Click here to login
×

You must be logged to download. Click here to login

×

MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

×

MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

How to develop portal using Liferay

In this article, we will learn about portal, portlet and how to develop a simple portlet using Liferay

A portal is used for building websites and web based applications. Each individual component in a portal is called a portlet. In other words a portal is an assembly of portlets.

Liferay Portal is a platform which allows us to create interactive portals.

Eclipse is a tool used to develop softwares. Using eclipse we can develop applications in Java and various other programming languages.

Now we will have a look at how to develop portals using Eclipse and Liferay.

Liferay Framework

Figure 1: Liferay Framework

Step -1: In this step, we will learn how to download and install Eclipse and Liferay.

http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/heliossr2

The above link will take us to a page from where we can download eclipse. We can see the list of options on the left side of the screen. We have to download eclipse which suits our operating system from the provided list. Once eclipse got downloaded unzip the downloaded file.

Liferay is available in the following link: http://www.Liferay.com/downloads/Liferay-portal/available-releases

We have to download ‘Liferay Portal 6.1 Community Edition’. In the drop – down select ‘Bundled with Tomcat’. It just means the Liferay which we are going to download will be downloaded along with tomcat server, and thus reducing the workload required for downloading and configuring a web server with Liferay.

The downloaded file needs to be extracted to any drive we prefer.

Step -2: In this step, we will learn how to configure Eclipse with Liferay.

Here are the step by step instructions on how to configure Eclipse with Liferay.

  1. Open Eclipse
  2. Go to Help
  3. In Help section select ‘Install New Software’ option
  4. Once step 3 is done a Dialog will open. In the Dialog , click Add .
  5. The dialog will ask for a name and Location. In name give any meaningful name and for Location give : http://releases.Liferay.com/tools/ide/eclipse/helios/stable/
  6. Select Ok.
  7. On completion of step 6, we can see some check boxes.
  8. Select all check boxes and click next.
  9. Click Finish to finish the process.

After the completion of above steps, eclipse will start downloading the required plugins for Liferay to make it available during development. This process, of downloading the required plugins may take a long time. Do not close eclipse as it will interrupt the process. Once eclipse finished downloading the plugins, a dialog box will appear asking us to restart eclipse. On restarting eclipse we can see Liferay is available for eclipse.

Alternatively, instead of using the URL, we can download an archieved update site from the following link and use it: sourceforge.net/projects/lportal/files/Liferay%20IDE/1.4.0/Liferay-ide-eclipse-updatesite-1.4.0.zip/download/

When the dialog box prompts for a URL just click archieve button and locate the folder in which you have downloaded the archieve and click OK. No need to extract the files from archieve.

Since we are using Liferay bundled with Tomcat web server we need not have to do any additional downloads for any web server.

Step -3: In this step, we will learn how to communicate with our Liferay software development kit (SDK) .

In order to start developing applications using Liferay we should have Liferay SDK and it should be made available for eclipse. For this, we have to download eclipse SDK from the below link: http://sourceforge.net/projects/lportal/files/Liferay%20Portal/6.1.1%20GA2/Liferay-plugins-sdk-6.1.1-ce-ga2-20120731132656558.zip/download

Once downloaded go to Window > Preferences > Liferay > Installed SDKs.

Here click the Add button and locate the installed SDK. Now Liferay SDK is available for development.

In order to make Tomcat server available for Liferay go to Window > Preferences > Server > Runtime Environments and click ‘Add’ in the left panel. On clicking ‘Add’ a dialog will appear , with a list of servers. Select Liferay v6.0(Tomcat 6) . Locate the Tomcat directory by clicking browse. Once the Tomcat directory is properly located, click ‘Ok’.

Now Liferay SDK and Liferay Tomcat Server is available within Eclipse for further developments.

Step -4: In this step, we will see how to start the server and view the Home page.

In Eclipse open the ‘Servers’ view. ‘Servers’ view will be usually available at the bottom. There if Tomcat was properly configured we can see the server appearing there. Right click the mouse button and click Start in the list of options. Server will start after one or two minutes. The URL in the browser will point to http://localhost:8080 . This is the default screen and the home screen of Liferay. Each and every content which we can see in the page is draggable, deletable and mainly each of them is a portlet.

On the top of the home page we can see a Menu, also called as Dock bar. In the menu we can see a ‘sign in’ link. We can sign in by clicking the link using default user name and password. You can login with default username and password.

Default User name: test@Liferay.com
Default Password:   test

Step -5: In this step, we will see how to create our first custom portlet.

In Eclipse window go to File->New->Project and select Liferay Project under Liferay option in the list of categories, and click ‘Next’.

It will take you to a new window. In that window, you will be asked for project name and Display name. Display name is not important. So whatever display name you prefer, or if already a display name is there by default that’s fine. But the field should not be blank. In the project name field, give some valid project name whichever you prefer.

Below, these fields you can also see a configuration section in the same window. Make sure that Liferay-plugins-sdk-6.0.6 and Liferay v6.0 CE (Tomcat 6) is located correctly.

Please not the versions may vary according to the Liferay bundle you have downloaded.

Below, the configuration section we can see the plugin type section where we can see options like Portlet, Hook, Ext, Layout, Theme. Each one of them is used for different purpose. In our case, we are going to create a simple portlet. So we have to make sure Portlet radio button is selected. Hooks are basically used for modifying the portlets that are already defined in Liferay. Layout and Themes are used for creating custom layouts and custom themes which are not already defined in Liferay. Ext is used to change the way of working, of an existing portlet that is predefined in Liferay. In other words, Ext is used to modify the functionality of an existing portlet.

After selecting the portlet radio button click ‘Next’.

In the next window we can see three radio buttons, with a header imfomation saying: ‘Select portlet framework’. The reason, the plugins which we have downloaded in step 2 and step 3 allows us to create portlets using Liferay, JSF and Vaadin. We need to select Liferay MVC. By default, Liferay MVC would have been selected. Now on clicking finish button we can see a project with the name which we have given already would have been created. All project names in Liferay will have –portlet as suffix.

Right click on the project name and create a new package. Now right click on the package which has been created and create a new class. This would have created a new java class in the package. In order to make it as a portlet class, the class should extend the MVCPortlet class and the supporting package ‘com.Liferay.util.bridges.mvc.MVCPortlet’ should be imported. This package is already available in Liferay sdk. If everything is properly configured then it should not show any errors. If you face any problem while extending MVCPortlet class or when importing the required package just re-do step 2.

Listing 1 : Shows the code to perform step 5

package com.Liferayproject.lportlet;
import com.Liferay.util.bridges.mvc.MVCPortlet;
public class FirstSample extends MVCPortlet{

}

Now in the project structure, we can see a folder by name docroot. Within docroot, we can see css, js, JSP folders. If any one of the folder is missing, we can just create one with same name. Once JSP folder is created, create a new JSP page inside the folder and name it as FirstSample.JSP. Inside the JSP give some data. Now your JSP will act as a portlet.

Step 6: In this step, we will see how to do an Ant Build .

Open the Ant window in eclipse. If Ant is not open then select Window-->Show View-->Ant menu option. In the project search for build.xml. Now drag the build.xml file to the Ant window. It will create a small ant icon in the Ant window. On double clicking the Ant eclipse will execute some commands. Each time any changes is made in the program or anything is added to the program this step should be executed.

Now stop the server and restart the server. In the home page you can see the Liferay portlet which you have created.

Conclusion

In this article, we have learnt about portal, portlets and how to create a cutom portlet using Liferay.



I have done my bachelor in Computer Science and I am well versed with programming languages such as JAVA, C#, html and done courses on Android development.

What did you think of this post?
Services
[Close]
To have full access to this post (or download the associated files) you must have MrBool Credits.

  See the prices for this post in Mr.Bool Credits System below:

Individually – in this case the price for this post is US$ 0,00 (Buy it now)
in this case you will buy only this video by paying the full price with no discount.

Package of 10 credits - in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download few videos. In this plan you will receive a discount of 50% in each video. Subscribe for this package!

Package of 50 credits – in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download several videos. In this plan you will receive a discount of 83% in each video. Subscribe for this package!


> More info about MrBool Credits
[Close]
You must be logged to download.

Click here to login