Sometimes, we need to put our property in properties file, because those properties might be changed in the near future. For example, in my twitter portlet, the twitter api I use to fetch tweets might be changed. A good design is to put the api url in properties. Later we don't need to change code and recompile the whole project. We only need to change the property value in properties file.
In Liferay, there are several ways to do that. Now I'd like to show the simplest way to do that.
1. create a properties file name portlet.properties in /WEB-INF/src folder
2. edit your portlet.properties like:
twitter.api=https://api.twitter.com/1/statuses/user_timeline.json?screen_name=
3. get the value of "twitter.api" in your controller or other classes
String value = com.liferay.util.portlet.PortletProps.get("twitter.api");
It's really easy, right?
I also found other ways to do that, but I haven't tried them.
http://www.liferay.com/community/wiki/-/wiki/Main/How+to+add+a+Properties+File+to+a+Portlet
http://www.liferay.com/community/wiki/-/wiki/Main/Adding+Custom+Properties