« Back to Wiki - Pending...

Adding Custom Properties

This article is pending deletion for not enough information. For more information, please see Wiki - Pending Deletion.

Introduction #

This guide explains how to do add your own custom properties in Liferay. It attempts to leverage the Liferay properties infrastructure to maintain consistency.

Requirements #

The only prerequisite to customizing your own set of properties is that the Liferay development environment is setup (see the topic Setting up the Extension Environment).

How it works #

This is a custom deployment -- there are however other ways of doing this.

  • Subclass com.liferay.portal.util.PropsUtil and define your custom properties. For example we created a class com.liferay.portal.util.USCPropsUtil:
package com.liferay.portal.util;
import com.liferay.portal.util.PropsUtil;
/* *
* This class extends the PropsUtil class for additional properties needed. *
public class USCPropsUtil extends PropsUtil {
        // Shibboleth Authentication properties        public static final String USC_AUTH_SHIB_UID = "usc.auth.shibboleth.uid";        public static final String USC_AUTH_SHIB_USCOWNERPVID = "usc.auth.shibboleth.uscownerpvid";        public static final String USC_AUTH_SHIB_MAIL = "usc.auth.shibboleth.mail";        public static final String USC_AUTH_SHIB_DISPLAYNAME = "usc.auth.shibboleth.displayname";//

// Shibboleth User Group properties }}}}//

*Add/map the custom properties to /ext-impl/classes/portal-ext.properties.  For example we created a section within portal-ext.properties for our custom properties:

## USC specific properties 

    # Shibboleth Authentication properties.  
    # These define the HTTP header variables that will contain the user attributes.
    # All variables must be populated otherwise the user cannot successfully authenticate.
  • Use it in your classes. For example we read our properties within our custom AutoLogin module. The value returned can optionally be passed through one of the methods in com.liferay.util.PrefPropsUtil to translate into various data types:
    try {
        companyId = PortalUtil.getCompany(req).getCompanyId();

        userScreenName = req.getHeader(PrefsPropsUtil.getString(companyId,USCPropsUtil.USC_AUTH_SHIB_UID));
        uscpvid = req.getHeader(PrefsPropsUtil.getString(companyId,USCPropsUtil.USC_AUTH_SHIB_USCOWNERPVID));
        mail = req.getHeader(PrefsPropsUtil.getString(companyId,USCPropsUtil.USC_AUTH_SHIB_MAIL));
        displayName = req.getHeader(PrefsPropsUtil.getString(companyId,USCPropsUtil.USC_AUTH_SHIB_DISPLAYNAME));
    catch (Exception e) {

Notes #

  • This has not been tested with Portlets!
  • This has been tested with Liferay Core

Related Articles #

Development in the ext environment

0 Attachments
Average (1 Vote)
The average rating is 2.0 stars out of 5.
Threaded Replies Author Date
Is this still a valid way to add custom... Dave Morris June 2, 2009 5:57 PM
I noticed that these properties are now stored... Dave Morris June 2, 2009 6:02 PM
I've done something to the point of: /* * *... Rob J Pontious June 4, 2009 12:28 PM
I was able to add a custom property by... Matthieu Levesque August 23, 2011 8:42 AM
In portal-ext add your own property... Mohammad Azharuddin May 31, 2013 7:51 AM
I have added property in portal-ext.properties ... Suman Chatterjee July 7, 2014 2:58 AM

Is this still a valid way to add custom properties in the ext environment? I'm getting this error when I try to follow this pattern:

Implicit super constructor PropsUtil() is not visible for default constructor. Must define an explicit constructor

This is because the PropsUtil constructor is private. Is this correct? What is the proper way to extend the portal-ext.properties file in Liferay 5.2.2?
Posted on 6/2/09 5:57 PM.
I noticed that these properties are now stored in PropsKeys.java

Maybe this is the correct class to extend. Can anyone confirm this? If so, I will update this wiki page, or create a new version.

Thanks for the help,

Dave Morris
Posted on 6/2/09 6:02 PM in reply to Dave Morris.
I've done something to the point of:

* This class extends the PropsUtil class for additional properties needed.
public class CustomPropsUtil extends PropsValues {

// Default phases
public static final String DEFAULT_VAR = PropsUtil.get("default.var");

In portal-ext.properties I've added a default.var with a value, but when I call as:

String defaultPhasesString = CustomPropsUtil.DEFAULT_PHASES;

I get a value of null returned. So I'm missing something somehow. But maybe that'll help you Dave?
Posted on 6/4/09 12:28 PM in reply to Dave Morris.
I was able to add a custom property by implementing the com.liferay.portal.kernel.util.PropsKeys and declaring final static string vars.

public class WebPortalKeys implements PropsKeys {
public static final String LCC_PORTAL_GRP_EMP = "lcc.portal.group.emp";
public static final String LCC_PORTAL_GRP_ETU = "lcc.portal.group.etu";

public static final String LCC_PORTAL_PORTAL_COMMUNITY_EMP = "lcc.portal.community.emp";
public static final String LCC_PORTAL_PORTAL_COMMUNITY_ETU = "lcc.portal.community.etu";

Using this call I was able to retreive the value "gr-emp" set in my portal-ext.properties:
PrefsPropsUtil.getString(companyId, WebPortalKeys.LCC_PORTAL_GRP_EMP);
Posted on 8/23/11 8:42 AM in reply to Rob J Pontious.
In portal-ext add your own property

And in Java use below code to get the values
import com.liferay.portal.kernel.util.PropsUtil;
String type = PropsUtil.get("showroom.city.names");
Posted on 5/31/13 7:51 AM in reply to Matthieu Levesque.
I have added property in portal-ext.properties


here myip is a end point url

but when i try to fetch the same in my ext impl class the value is coming as null
String strEndPointURL = PropsUtil.get("endpoint_url");
everything was working fine before but since i have made update to the file and redeployed it is not working.
As informed in other posts i have deployed and restarted my jboss server twice once for the extensive environment to load and second for other plugins to load but still with no success, any help would be appreciated
Posted on 7/7/14 2:58 AM in reply to mohammad azaruddin.