Tuesday, February 28, 2017

Liferay-IQ

Question:How to do we use Social features in Liferay
Question:How to add more than one content repository
Questions:How do we filter contents in Liferay
Question: How to implement Multilingual portal
Question:Faceted  Search
Question :Liferay DXP
Question:WorkFlow in Liferay
http://www.opensource-techblog.com/complete-liferay-guide

Question:How to access the portal.properties or portal-ext properties file in Liferay

How to properties file are read from Portlet ,what is their preferences.

portal.properties  found in /tomcat-7.0.25/webapps/ROOT/WEB-INF/lib/portal-impl.jar. We can override these properties (defined inportal.properties) from portal-ext.properties file.


portal-ext.properties file needs to be created manually and can be placed at following places
Location-1 : LIFERAY_HOME
Location-2 : Liferay_HOME/tomcat-7.0.25/webapps/ROOT/WEB-INF/classes.

On sever startup, Liferay reads portal properties from portal.properties file followed by portal-ext.properties file defined at location-1 then from location-2. Finally it reads from portal-setup-wizard.properties file.

Any properties defined in portal.properties file, can be overridden in portal-ext.properties defined at location-1.
Any properties defined in portal-ext.properties file at location-1, can be overridden in portal-ext.properties defined at location-2.

String newProp = PropsUtil.get("test.property");

Question: What are the contents of liferay-setup-wizard properties

Answer: admin user first name,last name,email,liferay home,database connection properties if set up with wizard.

Question: How to read from portlet.properties


There are 2 ways you can read properties file in liferay portlet.
1) Just create portlet.properties under src folder of your portlet and write some key value inside your portlet.properties file. You can read the key as 
String value = PortletProps.get("key");
2)You can load your own properties file with your custom name file. Create a class with the following  name
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class PropsUtil {
    
    private static Properties props = null;
    
    private  PropsUtil(){
        ClassLoader classLoader = getClass().getClassLoader();
        InputStream is = classLoader.
getResourceAsStream("resource/sample.properties");
        props = new Properties();
        try {
            props.load(is);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    private static synchronized Properties getProperty(){
        if(props == null){
            new PropsUtil();
            return PropsUtil.props;
        }else{
            return props;
        }
    }
    
    public static String get(String key){
        
        return getProperty().getProperty(key);
    }
}

Here resource/sample.properties is your properties file that's under src\resource folder. You can get the key value as bellow
String value = PropsUtil.get("key");