Monday, September 30, 2013

How to change page layout in Liferay

As a popular Content Management System (CMS), Liferay allowed users to personalize their own page layout.

As long as the users are given required permission, they are authorized to change their workspace layout.

By default, Administrator and Power User are roles given this permission.

Steps to personalize page layout in Liferay,
1. Login to Liferay with the Administrator role or Power User role.

2. navigate to the Page Layout dialog.
    Manage > Page Layout

3. Choose preferred page layout, then click Save.


Saturday, September 28, 2013

Creating hyperlink with JSF components

normally JSF components accept an outcome from navigation case to generate hyperlink.
<h:link value="my link" outcome="MY_OUTCOME" />

<h:commandButton value="my button" action="MY_OUTCOME" />

<h:outputLink value="MY_OUTCOME">my link</h:outputLink />

But hyperlink generated with JSF outcome is only within the same application.
That's mean hyperlink generated with JSF components are unable to navigate to other sites. eg,

This problem could be resolved by <h:outputLink /> where the value attribute also accepts an URL.
<h:outputLink value="">
    <h:outputText value="Google" />
    <f:param name="param1" value="value1" />
    <f:param name="param2" value="value2" />

With the above codes, the <h:outputLink /> component able to generate hyperlink to

<f:param /> is optional, required only when passing parameters


Wednesday, September 25, 2013

How to retrieve logged in user model in JSF2 Portlet

Retrieving logged in user is essential in every system, especially for logging purpose or authentication and authorization.

Steps to retrieve Liferay Logged in user in JSF portlet:
1. get the PortletRequest from JSF context
    PortletRequest portletRequest = (PortletRequest) FacesContext                                                                 .getCurrentInstance()

2. get the logged in user id
    String userId = portletRequest .getRemoteUser();

3. get the user model with Liferay API
    User user = UserServiceUtil.getUserById(Long.valueOf(userId));


Sunday, September 22, 2013

Setting default user role, group, and site for a user in Liferay

The objective of this post is to show how to define role, group, site for a user especially when create a new user in Liferay.

meaning when creating a new user, what are the roles/groups/sites that are given to the user, unless intentionally changes it to other role/group/site.

To set the default user's role/group/site, follow the steps below:
1. Login as Liferay administrator.

2. Navigate to Default User Assiciations
    Go to > Control Panel > Portal > Portal Settings > Users > Default User Associations

3. Enter desired settings into the textbox.
    eg. if the Power User removes from the Roles textbox, that means new users created after this would have User role only, which is a limited authority role in Liferay.
    same applicable for Sites and User Groups, once defined in the textbox, it would be the default settings for newly created users, unless purposely changes it during create users.


Thursday, September 19, 2013

Currency formatting with <f:convertNumber />

due to internationalization, the system should system the currency based on users' chosen currency or locale.
12345678.36 in US display as 12,345,678.36
12345678.36 in Danish (Denmark) display as 12.345.678,36
12345678.36 in German (Switzerland) display as 12'345'678.36

this could be easily handled by <f:convertNumber />, otherwise we might need to write a custom converter to handle this.

with <f:convertNumber />, we just need to pass in the system locale for the conversion.
<h:outputText id="balance" value="#{user.balance}">
    <f:convertNumber type="currency" locale="#{facesContext.viewRoot.locale}" />
with the above code, system will dynamically format the text value with system provided locale.

Monday, September 16, 2013

How to configure Mail server settings in Liferay

To configure Mail server settings in Liferay,
first must login with administrator role. and then perform the following steps.

1. Navigate to Mail server settings page.
    Go to > Control Panel > Server > Server Administration > Mail

2. Enter valid incoming (POP) and outgoing (SMTP) mail server settings

3. Save


Friday, September 13, 2013

Alignment issue on p:selectOneMenu

When <p:selectOneMenu /> aligns with other components.
It is align slightly upper than other components.

To resolve this issue.
simply put each component into each individual <td /> or a panelGrid to wrap the components.
<h:panelGrid columns="3">
  <p:commandButton value="test"></p:commandButton>
    <f:selectItem itemLabel="select" itemValue=""/>



Tuesday, September 10, 2013

How to delete user(s) in Liferay

To delete user(s) in Liferay, we must login to Liferay Portal with Administrator role.

1. Navigate to Users and Organizations
    Go to > Control Panel > Portal > User and Organization

2. Choose user(s) to deactivate

3. Search all inactive user(s).
    a) Click the Search All Users link
    b) Choose Inactive in the Status dropdown
    c) Click Search

4. Choose user(s) to delete from the inactive list.


Saturday, September 7, 2013

How to pass parameters with p:remoteCommand

In some cases, we might want to invoke an server side action via java script.
This can be done by <p:remoteCommand />.
with <p:remoteCommand />, we could assign a name to the remoteCommand component, then invoke the remoteCommand's action with the given name
<p:remoteCommand name="rcTest"
    update="any_component_id" />

<p:commandButton value="remote command test" onclick="rcTest();" />

In Addition, we might want to pass in some parameters to our server side action with the following syntax.
<p:commandButton value="remote command test" 
    onclick="rcTest([{name:'myName1',value:'myValue1'},{name:'myName2',value:myValue2}]);" />

Tuesday, September 3, 2013

How to create side menu layout with p:menu

The objective of this post is to create side menu layout as below.

1. create a side menu template
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns=""

<h:head />
                <td><ui:insert name="sidemenu" /></td>
                <td><ui:insert name="content" /></td>

Sunday, September 1, 2013

How to create side menu layout with p:tabView

The objective of this post is to develop below layout with <p:tabView /> component.

With the tabView component, the above layout could be easily developed with the orientation attribute.
<p:tabView orientation="left">
    <p:tab title="tab1">
        <h:outputLabel value="this is tab 1" />
    <p:tab title="tab2">
        <h:outputLabel value="this is tab 2" />


related topic.
How to create side menu layout with p:menu



Related Posts Plugin for WordPress, Blogger...