Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Tim Cardwell
Declaring constants in a properties or config file
September 17, 2012 10:45 AM
Answer

Tim Cardwell

Rank: Junior Member

Posts: 27

Join Date: July 19, 2012

Recent Posts

I have a couple of string constants that I want to put in a config or properties file, and from what I read I would put them in service-ext.properties (I'm building a service), but I can only seem to find service.properties. Where exactly would the file I should be modifying be?

Another question: When I need to read these constants I do something like this...

1
2Properties properties = new Properties();
3FileInputStream fis = new FileInputStream(PATH_TO_FILE);
4properties.load(fis);
5
6properties.getProperty(keyName);


However, when I add the service to my portal, I'm really adding the WAR file. Will a direct reference to the properties file be available? Or should I load the properties file a different way?

Thanks,
-Tim
Samuel Kong
RE: Declaring constants in a properties or config file
September 17, 2012 10:44 PM
Answer

Samuel Kong

LIFERAY STAFF

Rank: Liferay Master

Posts: 946

Join Date: March 10, 2008

Recent Posts

You probably don't want to use service.properties.

Here's how I would do it:

1) In your plugin, create: /docroot/WEB-INF/src/portlet.properties
2) Add whatever you want in the properties file
3) From your Java/JSP, call: com.liferay.util.portlet.PortletProps.get("name.of.your.property.key");