Wednesday, 26 February 2014

Hide Liferay Default Messages

Liferay by default displays a Success or Error message when a form is submitted.
If you wish to hide the default message that Liferay displays when a form is submitted, add the below lines of code to your Methods in your Portlet Class.

For Liferay 6.1 & below, both messages are hidden with the line of code below.
SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);

For Liferay 6.2, we have to hide Success as well as Error Messages separately.
// Hide default Success Message
SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_SUCCESS_MESSAGE);

// Hide default Error Message
SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
OR
We can add the below lines to the portlet.xml file to remove all such messages from our portlet.
<init-param>
  <name>add-process-action-success-action</name>
  <value>false</value>
</init-param>

Comments / suggestions are always welcome.

No comments :

Post a Comment