Archive for the ‘Liferay Articles’ 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.

Add themes to your project

1) Open command prompt or terminal and go to your project directory. Next we are going to create a theme using the Liferay theme template. Run:

mvn archetype:generate \
-DarchetypeArtifactId=liferay-theme-archetype \
-DarchetypeGroupId=com.liferay.maven.archetypes \
-DarchetypeVersion=6.1.0 \
-DartifactId=sample-theme \
-DgroupId=com.liferay.sample \
-Dversion=1.0-SNAPSHOT
For 6.1 EE ga1 use -DarchetypeVersion=6.1.10.

Now you have your theme project in sample-theme directory with following structure.

sample-theme
sample-theme/pom.xml
sample-theme/src
sample-theme/src/main
sample-theme/src/main/resources
sample-theme/src/main/webapp
sample-theme/src/main/webapp/WEB-INF
sample-theme/src/main/webapp/WEB-INF/liferay-plugin-package.properties
sample-theme/src/main/webapp/WEB-INF/web.xml

2) Open the theme pom.xml file. From the properties section remove liferay.version and liferay.auto.deploy.dir properties. These properties should be defined in the pom.xml in your project root just as we did with the portlet project.

You should also note that there’s two additional properties liferay.theme.parent and liferay.theme.type. These set the parent theme and the theme template language just like in ant based plugins sdk. The property liferay.theme.parent however allows you to define basically any war artifact as the parent. The syntax is groupId:artifactId:version or you can use the core themes:_unstyled_styledclassic and control_panel.

3) Now you can add your customizations in src/main/webapp. Just follow the same structure as you would do in _diffs. So your custom.css would go to src/main/webapp/css/custom.css.

4) Once you’ve done your customizations and want to create the war file just run

mvn package

It will create the war file just like with any maven war type project. Another thing it will do is download and copy your parent theme and then overlay your changes on top of it. It will also create a thumbnail from src/main/webapp/images/screenshot.png just like ant based plugins sdk does. These are accomplished by adding the theme-merge and build-thumbnail goals into the generate-sources phase.

5) Now deploy the theme into your Liferay bundle by running:

mvn liferay:deploy

Liferay Portal is ideal for setting up collaboration environments among workgroups. Whether you call these environments communities or virtual team rooms, Liferay can be used to help your team get their work done. It does this by providing applications that are geared specifically toward document sharing and communicating with one another.
One of the portlets you can add to a page in Liferay is Document Library. This application provides a facility for sharing documents with your entire team. It keeps a complete version history of all your documents and is integrated with Liferay’s permissions system. This integration allows you to grant access to shared documents or prevent some of your users from accessing sensitive documents. And if your users need an easier way to access the documents than the web interface provides, Document Library supports WebDAV, allowing documents to be uploaded and downloaded through their operating system’s native interface.

Documents are one thing, but what about communication? Liferay’s portlets allow for communication in context, so your users can keep all the relevant information in the right place. Document Library allows your users to create discussion threads next to the documents they need to talk about. Wiki does the same thing. And applications
are provided for both chat and email, so that currently logged-on users can communicate in real time no matter what their physical distance is from one another.

If you have lots of web content and wish to publish that content using a workflow or on a schedule, statically or dynamically, to staging or production, with templates or without, then you may want to check out Liferay’s CMS.
You can access the web-content functions from the same Applications window you’ve already seen; they’re in their own category. But the quickest way to do it is to select Web Content Display from the Add menu. It’s on the menu for convenience—if you’re building a content-rich web site, you’ll use it a lot. After it’s added, you can drag it to whatever position on the page you want.

The Web Content Display portlet does what its name implies: it displays web content. In order for it to do its job, you’ll have to create some web content. You can do that quickly by clicking the Add Web Content icon at lower right. You’re then brought to a form where you can add content

Getting to know Liferay

Posted: April 12, 2012 in Liferay Articles

Liferay Portal is an open source project that uses the Lesser General Public License (LGPL). This is the GPL license you know and love, with one important exception: Liferay can be linked to software that isn’t open source. As long as you use Liferay’s extension points for your custom code, you don’t have to release your code as open source if you don’t wish to. You can keep it, sell it, or do whatever you want with it; it’s yours. But if you make a change to Liferay itself by modifying Liferay’s source code and want to redistribute the product thereafter, then you need to contribute that change back to Liferay. You get an important exception with the LGPL: you can use Liferay as a base for your own product and either open-source the result or sell it commercially if you wish. Or, if you want to change Liferay directly, you can contribute to the open source project. It’s entirely up to you. You can download the open source version of Liferay Portal for free from Liferay’s web site.
Alternatively, Liferay sells an Enterprise Edition of Liferay Portal. This is a commercially available version of the product that comes with support and a hot-patching system for bug fixes and performance improvements. There are web sites running on both
versions of Liferay Portal, and both are perfectly appropriate for serving up your site. In this section, we’ll take a quick tour of some of the things you can do with Liferay to begin building a web site. You’re going to play around with the interface a bit so you can get to know it better. Figure 1.2 shows the default Liferay Portal 6 user interface.
Okay, I agree; it doesn’t look like much, does it? But there’s an awful lot of power hidden in the humble interface that Liferay shows you by default. If you’re ahead of the game and already have Liferay running, you can follow along. If not, sit back and enjoy the ride: we’ll go over how to get Liferay installed and running on your system.

Liferay Example Websites

Posted: April 3, 2012 in Liferay Articles

false EN-US X-NONE X-NONE

Here’s a brief outline of how you can use your own security system in Liferay.
• Create your own PermissionChecker class that extends Liferay’s PermissionChecker class.
• Register this new class in portal.properties (or portal-ext.properties for the EXT environment) under the permissions.checker property.
• Override the hasUserPermission(…) method and the hasGuestPermission(…) method with your
own calls to your permission system.
• You can call the setValues(…) method to pull in parameters from the request object that your permission
checker might need (e.g., userId, projected, etc).
• You can call the resetValues(…) method to wipe out old parameters.
• Override the isAdmin(…) method.

IFrame in Liferay

Posted: April 3, 2012 in Liferay Articles

false EN-US X-NONE X-NONE IFrame Control in Liferay

1. This portlet is defined in /portal-web/docroot/WEB-INF/portlet.xml.
48
IFrame
com.liferay.portlet.IFramePortlet
0
text/html
edit
com.liferay.portlet.StrutsResourceBundle
src
auth
false
auth-type
basic
form-method
post
user-name
password
hidden-variables
var1=hello;var2=world
Power User</role-name
User
The unique id associated with this portlet is 48. The IFramePortlet class extends javax.portlet.GenericPortlet.
The source [http://content.liferay.com/document/api/portal-ejb/com/liferay/portlet/IFramePortlet.java.html] of
this class shows that this class prints an IFRAME tag that references an external site. This portlet is editable
and viewable by HTML browsers. The preferences bind the name src with the default value of http://www.gfa.org.
The auth value, if set to true, will attempt to authenticate the user to the external IFrame application. The authtype value can be set to basic or form. Basic authentication appends the login information to the URL and form
authentication requires a post to the external IFrame application. The form-method value can be set to get or
post. This is only used if you are using form authentication. The user-name value sets the user name for authentication. If you are using basic authentication, then you just need to set the user name. If using form authentication, you need to set the user name as a key value pair like acme_login=test@acme.com. The password
value sets the password for authentication. If using basic authentication, you just need the password. If using
form authentication, set the password as a key value pair like acme_password=password. The hidden-variables value is used for form authentication. Some forms require certain prepopulated fields in order to proceed
with authentication. Separate each key and value with a = and each key value pair with a ;. Users must have
either the Power User or User role to access this portlet. The roles can be changed at run time via the Admin
portlet.
2. The title is fetched by StrutsResourceBundle and is configured in /
portal-ejb/classes/content/Language.properties.
javax.portlet.title.48=IFrame
3. Additional definitions for this portlet are found in /portal-web/docroot/WEB-INF/liferay-portlet.xml.
The id value in liferay-portlet.xml must match the portlet-name value in portlet.xml. The struts-path value
tells Struts that all requests starting with http://localhost/c/iframe/* are considered part of this portlet’s scope.
See the Mail portlet to better understand this feature.
4. Display information for this portlet is found in /portal-web/docroot/WEB-INF/liferay-display.xml and makes it
possible for users to add this portlet via the personalize pages screen.
When a user goes to personalize pages and clicks on a category to choose a portlet, the IFrame portlet is available under the category with the name that matches the key category.test. The value for this key is defined in /
portal-ejb/classes/content/Language.properties.
category.test=Test

Calendar in Liferay

Posted: April 3, 2012 in Liferay Articles

false EN-US X-NONE X-NONE Calendar Control in Liferay

1. This portlet is defined in /portal-web/docroot/WEB-INF/portlet.xml.

8
Calendar
com.liferay.portlet.JSPPortlet

view-jsp
/portlet/calendar/view.jsp

0

text/html

com.liferay.portlet.StrutsResourceBundle

Power User

User

The unique id associated with this portlet is 8. The JSPPortlet class extends javax.portlet.GenericPortlet. The
source of this class shows that this class looks for the init parameters and forwards to the appropriate JSP depending on the portlet mode. This portlet is viewable by HTML browsers. Users must have either the Power
User or User role to access this portlet. The roles can be changed at run time via the Admin portlet.
2. The title is fetched by StrutsResourceBundle and is configured in /
portal-ejb/classes/content/Language.properties.
javax.portlet.title.8=Calendar
3. Additional definitions for this portlet are found in /portal-web/docroot/WEB-INF/liferay-portlet.xml.
<portlet
id=”8″
struts-path=”calendar”
scheduler-class=”com.liferay.portlet.calendar.job.Scheduler”
preferences-sharing-type=”user”
show-portlet-access-denied=”true”
show-portlet-inactive=”true”
</
The id value in liferay-portlet.xml must match the portlet-name value in portlet.xml. The struts-path value tells
Struts that all requests starting with http://localhost/c/calendar/* are considered part of this portlet’s scope. See
the Mail portlet to better understand this feature. The scheduler-class value must be a class that implements
Scheduler and is called to schedule Quartz jobs for this portlet. The preferences-sharing-type value indicates
the preferences sharing type of the portlet. If set to none, preferences are not shared and each page will have its
own set of preferences. If set to user, preferences are shared by user if the portlet is in a personal page or by
group if the portlet is in a group page. If set to company, preferences are shared across the entire company. The
show-portlet-access-denied value, if set to true, means non-permissioned users are shown that they do not have
access to the portlet. The default value is set in portal.properties. The show-portlet-inactive value, if set to true,
means users are shown that the portlet is inactive (if the portlet is inactive). The default value is set in
portal.properties

4. Display information for this portlet is found in /portal-web/docroot/WEB-INF/liferay-display.xml and makes it
possible for users to add this portlet via the personalize pages screen.

When a user goes to personalize pages and clicks on a category to choose a portlet, the Calendar portlet is
available under the category with the name that matches the key category.community. The value for this key is
defined in /portal-ejb/classes/content/Language.properties.
category.community=Community
 

We are proud and passionate about super clean code. Wrap lines at 80 spaces and use real tabs equivalent to 4spaces. Follow the Java Code Conventions and read

The Elements of Java Style. And ABOVE all else, follow thprecedence of the rest of the code.