Posts

Showing posts from November, 2012
Configuration Properties Properties Reference These are the portlet preference user guide       http://www.liferay.com/documentation/liferay-portal/6.1/user-guide/-/ai/configuring-liferay-s-properti-1

Get URL of Portlet By Passing Portlet ID

HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(portletRequest);                              httpRequest = PortalUtil.getOriginalServletRequest(httpRequest) long plid = PortalUtil.getPlidFromPortletId(themeDisplay.getScopeGroupId(), portletID);   PortletURL portletURL = PortletURLFactoryUtil.create(httpRequest ,portletId, plid ,PortletRequest.RENDER_PHASE);

Difference Between == & equals()

This is one of the frequently asked question in Interview. == always checks for reference equality.Means If  2 references points to same Object == gives you true equals() is a method available in java.lang.Object class and this method is overrided by many child class including String. Note:- If somebodys asks you,the differences between == and equals(),You should reverse question them for clearity,If he is talking about java.lang.Object.equals() or some other class equals() There is no difference between == and equals() of Object class. equals() of Object class internally uses == operator for comparing the object reference. source code of java.lang.Object class public class Object { public boolean equals(Object obj) {  return (this == obj);     } } equals() of String class checks if the string content is equal or not(case-sensitive) String s1=”hello”; String s2=”hello”; s1.equals(s2);//gives true. Since it is string pooling,only 1 object will  be created and shared b
void and Void void is a keyword which is used to specify the return type of a method.When a method return type is void,it means,the method is not going to return anything Void is a class with private constructor,Hence we cannot create the object of such class. What is the Use of Void class? It is use to know the return type of a method,via reflection api. Assume you have a Demo class with a show() method public class Demo { public void show(){} } Now Based on the return type(If return type is void do something) else do someother thing So the code to find out the return type is Class c1 =Demo.class.getMethod("show",null).getReturnType();  if(c1 == Void .TYPE) { //Some Business logic when return type is void } The complete program is VoidDemo.java import java.util.List; class Demo {     public void show()     {             } } public class VoidDemo {     public static void main(String[] args) throws NoSuchMethodException,SecurityExcept