Forums de discussion

Refresh portlet ( asset publisher )

thumbnail
Soukaina HAJI, modifié il y a 9 années.

Refresh portlet ( asset publisher )

Regular Member Publications: 195 Date d'inscription: 17/06/14 Publications récentes
Hello
I need to refresh a portlet (asset publisher ) every 5 minutes

Liferay 6.2 ce ga2

Thank you
thumbnail
David H Nebinger, modifié il y a 9 années.

RE: Refresh portlet ( asset publisher )

Liferay Legend Publications: 14917 Date d'inscription: 02/09/06 Publications récentes
javascript.
thumbnail
Soukaina HAJI, modifié il y a 9 années.

RE: Refresh portlet ( asset publisher )

Regular Member Publications: 195 Date d'inscription: 17/06/14 Publications récentes
I know It would be some script in javascript or alloyUi ...
I think I found this file add_asset_redirect.jsp which contain the script to refresh the portlet :


<%
String redirect = request.getParameter("redirect");

redirect = PortalUtil.escapeRedirect(redirect);

Portlet selPortlet = PortletLocalServiceUtil.getPortletById(company.getCompanyId(), portletDisplay.getId());
%>
<aui:script use="aui-base">
	Liferay.fire(
		'closeWindow',
		{
			id: '<portlet:namespace />editAsset',
			portletAjaxable: &lt;%= selPortlet.isAjaxable() %&gt;,

			<c:choose>
				<c:when test="<%= redirect != null %>">
					redirect: '&lt;%= HtmlUtil.escapeJS(redirect) %&gt;'
				</c:when>
				<c:otherwise>
					refresh: '&lt;%= portletDisplay.getId() %&gt;'
				</c:otherwise>
			</c:choose>
		}
	);
</aui:script>


So I inserted a timer in there but it doesnt work :

&lt;%
String redirect = request.getParameter("redirect");

redirect = PortalUtil.escapeRedirect(redirect);

Portlet selPortlet = PortletLocalServiceUtil.getPortletById(company.getCompanyId(), portletDisplay.getId());
%&gt;

<aui:script use="aui-base">
YUI().use("console", "console-filters", "substitute", "node-event-simulate",
   function(Y) {

     var doSomething = function(e) {
			id: '<portlet:namespace />editAsset',
			portletAjaxable: &lt;%= selPortlet.isAjaxable() %&gt;,

			<c:choose>
				<c:when test="<%= redirect != null %>">
					redirect: '&lt;%= HtmlUtil.escapeJS(redirect) %&gt;'
				</c:when>
				<c:otherwise>
					refresh: '&lt;%= portletDisplay.getId() %&gt;'
				</c:otherwise>
			</c:choose>
		}
     };

     IntervalId = setInterval(doSomething, 1000);
 });
</aui:script>


thank you
thumbnail
David H Nebinger, modifié il y a 9 années.

RE: Refresh portlet ( asset publisher )

Liferay Legend Publications: 14917 Date d'inscription: 02/09/06 Publications récentes
have you set a breakpoint inside of the script to see if the timer's working? And why throw YUI into the mix, I think you should stick with AUI.
thumbnail
Soukaina HAJI, modifié il y a 9 années.

RE: Refresh portlet ( asset publisher )

Regular Member Publications: 195 Date d'inscription: 17/06/14 Publications récentes
The solution:

Step1 : Go to "Admin" > "site administration" > "Private pages" >
Step 2 : Insert the following script in Javascript" in the right side:

function refreshPortlet(){
          Liferay.Portlet.refresh('.portlet-asset-publisher');
           setInterval(refreshPortlet, 300000); 
}
refreshPortlet();



Hope it helps