Posts

Showing posts with the label refresh

Refreshing the portlet at certain intervals in liferay

In our Project we have requirement to refresh the portlet at certain interval of times. Thanks to liferay we have utility method to get the refreshURL. Have a look into the  PortletURLUtil class. we have  getRefreshURL (---....)  method to the current portlet URL. So we have used in the following way in the jsp. As already we know "request" and "themeDisplay" Objects are predefined objects. <%@page import="com.liferay.portlet.PortletURLUtil"%> <script type="text/javascript"> setTimeout(openUrl, 5000); // Wait 5 seconds function openUrl(){    window.open('<%=PortletURLUtil.getRefreshURL(request, themeDisplay) %>'); } </script> Thats it will refresh the portlet for every 5 seconds. In  PortletURLUtil   also we have one more method to clone the URL,  clone (----) public static PortletURL clone( PortletURL portletURL, MimeResponse mimeResponse) throws PortletException { ---- --- } ...

Avoiding Multiple Submits(Refresh page) in Liferay

We often see after submitting the form and refresh the page you will see the same result will be adding in the DB. So how to get rid of this? Here we have 2 options to eliminate this behaviour. 1. By Declaring the tag in the liferay-portlet.xml after <icon> tag           <action-url-redirect> true </action-url-redirect> 2.After doing our logic we can redirect to specified URL by using actionResponse.    actionResponse.sendRedirect(PortalUtil.getLayoutURL(themeDisplay.getLayout(),themeDisplay));   Here we are  redirecting to the friendly url of that page. The above will be redirect to the below URL as                     //group/test/test1----- (group/<your-community-name>/pageName) .

Refreshing the portlet through the javascript

Some times it may require our portlet when some action performed. We can refresh liferay portlet through the javascript. <script type="text/javascript"> jQuery(document).ready(function() {           Liferay.Portlet.refresh('#p_p_id_ testjson_WAR_testjson _'); } </script> Bold word is the portlet name