Posts

Showing posts from 2016

Getting the modal hints for the column in class

We will update the maxlength for the column in portlet-modal-hints.xml. Just like as below <field name="comments" type="String"> <hint name="max-length">500</hint> </field> If we want to get these max length in the class,  we can use the below code. ModelHintsUtil.getMaxLength(model, field) model : Class name field : columnName ex: ModelHintsUtil.getMaxLength(KBUser.class.getName(), "comments");

Debug the Mail in liferay

To turn on logging of Liferay mail and JavaMail, add the following to your Log4j configuration in  webapps/ROOT/WEB-INF/class/ META-INF/portal-log4j-ext.xml  after the last  <appender>  entry: <logger name="com.liferay.util.mail"> <level value="DEBUG"/> </logger>

Analyzing the Portlet Performance in liferay

Set the following log in the  tomcat/lib/META-INF/portal-log4j-ext.xml <category name="com.liferay.portlet.InvokerPortletImpl">        <priority value="DEBUG" />     </category> This will cause the performance of each portlet render to be logged, for example:  render for welcomeportlet_WAR_welcomeportlet takes 1 ms render for employmentportlet_WAR_linksportlet takes 80 ms

Difference between System Exception and Portal Exception

SystemException  This  Exception caused by system problems. Examples include database connection errors and file not found errors.   System exceptions are always unexpected , and generally indicate that the   portal is misconfigured or that a critical service is unavailable. PortalException  This exceptions related to business logic. Examples include invalid input, portlet errors, and references to non existent database records.   Portal exceptions are generally caused by user error , and do not indicate that anything is wrong with the portal itself.

Creating the URL programmtically

Hi, Below is the code ,to create the different types of request URL. As we know in Liferay we have 3 types of URL 1.ActionRequest 2.RenderRequest 3.ResourceRequest. //Create Render URL PortletURL renderURL = PortletURLFactoryUtil.create( actionRequest,PortalUtil.getPortletId(actionRequest), themeDisplay.getLayout().getPlid(), "0"); renderURL.setParameter("customparam","customvalue"); actionResponse.sendRedirect(renderURL.toString()); If you want to create the ActionRequest put 1 instead of 0 in the last argument. We can check the code in the  PortletURLImpl class of liferay if (_lifecycle.equals(PortletRequest.ACTION_PHASE)) { _reservedParameters.put("p_p_lifecycle", "1"); } else if (_lifecycle.equals(PortletRequest.RENDER_PHASE)) { <_reservedparameters .put="" _reservedparameters.put="" else="" if="" lifecycle.equals="" ortletrequest.resource_phase="&q