Pages

Friday 23 May 2014

portal.properties: Load properties from external file

Hi,
        This topic is simple but mandatory for developer to go through with it since this comes with best practices.


1. Include "com.liferay.util.portlet.PortletProps" package into your jsp or in java


2. Make a properties file & put into source folder of your portlet named as portal.properties.


3. put some entries in that file like
                 my_custom_message=this is from your external properties files

4. Now you can fetch the properties by the following way:


  • In Jsp

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
               <portlet:defineObjects />
               <%@ page import="com.liferay.util.portlet.PortletProps" %>
               <%= PortletProps.get("messages.per.page") %>

                



  • In  Java
import com.liferay.mail.util.PortletProps;

PortletProps.get("messages.per.page");



No comments:

Post a Comment