Archive for the ‘Tutorial’ Category

At this point you have all the portlets you want on your page and you’ve created and logged in with your own user. For security, delete the test user that you logged in with in the previous section. To delete the test user, click on the Users tab in Enterprise Admin portlet and search for the test user. Click on the Delete icon

You can now change the look and feel of your portal. Liferay Portal comes pre-bundled with different themes that you can apply to your page.
Changing the Theme
• Click on the Page Settings link at the top of your page.
• Select the page you would like to theme on the left hand side. Note that by default all children pages will inherit the theme from the parent.
• Now select the Look and Feel tab for that page.
• You will see a number of bundled themes that are available with Liferay Portal. Choose your theme and color scheme. You can experiment with it as much as you like until you find a theme that pleases you. Don’t spend too much time here now… time to move on…
NOTE: Although Liferay comes with many bundled themes, there are also a vast number of themes contributed to Liferay Portal from the community. You can view these on our website or develop your own custom theme for your company or application. Please read the Building Themes chapter in the Liferay Portal Developers Guide.

Simple JSP Portlet

Posted: April 12, 2012 in Liferay Examples, Tutorial

Although a JSPPortlet does little more than display content, there is still some work that needs to be done. Let’s start by creating a new directory called myjspportlet within {Liferay}\ext\ext-web\docroot\html\portlet\ext\. Next,
open portlet-ext.xml within {Liferay}\ext\ext-web\docroot\WEB-INF\.
Note: You may need to associate .xml files to Eclipse if your .xml files are being opened in a separate editor. You can do this by selecting Window from the menu bar and then Preferences. Expand the Workbench navigation, and click on File Associations. From there you can add *.xml as a new File type and associate it to open in Eclipse.
Notice how the portlets are uniquely identified by their portlet-name. As such, you will want to create a new portlet that is an increment of the portlet name, such as EXT_2. Since we are creating a JSPPortlet, you will want the portlet-class to reference the full class name: com.liferay.portlet.JSPPortlet. For this tutorial, add the following to your portlet-ext.xml (you may find it easier to copy and paste EXT_1 and just make the necessary changes):

<portlet>
<portlet-name>EXT_2</portlet-name>
<display-name>My JSPPortlet</display-name>
<portlet-class>com.liferay.portlet.JSPPortlet</portlet-class>
<init-param>
<name>view-jsp</name>
<value>/portlet/ext/myjspportlet/view.jsp</value>
</init-param>
<expiration-cache>300</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<portlet-info>
<title>My JSP Portlet</title>
</portlet-info>
<security-role-ref>
<role-name>Power User</role-name>
</security-role-ref>
<security-role-ref>
<role-name>User</role-name>
</security-role-ref>
</portlet>
Here is a basic summary of what each of the elements represents:
portlet-name The portlet-name element contains the canonical name of
the portlet. Each portlet name is unique within the portlet
application.
display-name The display-name type contains a short name that is intended to be displayed by tools. It is used by displayname elements. The display name need not be unique.
portlet-class The portlet-class element contains the fully qualified
class name of the portlet.
init-param The init-param element contains a name/value pair as an
initialization param of the portlet.
expiration-cache Expiration-cache defines expiration-based caching for
this portlet. The parameter indicates the time in seconds
after which the portlet output expires. -1 indicates that
the output never expires.
supports The supports element contains the supported mime-type.
Supports also indicates the portlet modes a portlet supports for a specific content type. All portlets must support the view mode.
portlet-info Portlet-info defines portlet information.
security-role-ref The security-role-ref element contains the declaration of
a security role reference in the code of the web application. Specifically in Liferay, the role-name references
which role’s can access the portlet. (A Power User can
personalize the portal, whereas a User cannot.)
Now that you have configured your portlet-ext.xml, the next step is to create the jsp pages. Within your /
myjspportlet directory, add a file called init.jsp. Within this file, add the following two lines of code:
<%@ include file=”/html/common/init.jsp” %>
<portlet:defineObjects />

These two lines import all the common class files and also set common variables used by each portlet. If you need to
import portlet specific classes or initialize portlet specific variables, be sure to add them to their directory specific
init.jsp, as opposed to the common/init.jsp.
These two lines import all the common class files and also set common variables used by each portlet. If you need to
import portlet specific classes or initialize portlet specific variables, be sure to add them to their directory specific
init.jsp, as opposed to the common/init.jsp.
Now, add a view.jsp. This jsp file will hold the content of your JSPPortlet. Write “Hello [your name here]# within
the jsp. So the question is then, how does the portal know how to load these particular files? If you look back at the
portlet element that was added within portlet-ext.xml, you will notice that you initialized a view-jsp parameter as
having the value /ext/myjspportlet/view.jsp. By specifying this init-param, you are giving the portlet a
default jsp to load.
Finally, in order to be able to add your portlet to the portal, you need to define the name within Languageext.properties by adding the following line:
javax.portlet.title.EXT_2=My JSP Portlet
Since you have setup the Extension Environment, you need to deploy the changes you have made to your applicable
server by running deploy within the build.xml of {Liferay}\ext\. In Eclipse, double click the deploy [default] target
within your Ant view. Start Tomcat again as soon as the deployment finishes. Browse to the Home tab of the portal,
and in the Add Portlet to Wide Column dropdown add “My JSP Portlet# to your portal.

liferay portal quick start guide

Posted: March 29, 2012 in Tutorial

Liferay Development Guide

Posted: February 22, 2012 in Tutorial

Liferay Portal 6.1 – Development Guide

  1. Preface
  2. Introduction
  3. The Plugins SDK
  4. Portlet Development
  5. Creating Liferay Themes
  6. Hooks
  7. Ext plugins
  8. Liferay IDE
  9. Liferay APIs
  10. Liferay Frameworks
  11. Resources for Liferay Developers
  12. Conclusions