简体   繁体   中英

Refreshing a single portlet in Liferay

I have a problem with refreshing a single Liferay portlet. I wrote a bit of javascript code to refresh a single Liferay portlet every 120s:

function refreshPortlet() {
    Liferay.Portlet.refresh("SOME_KEY")
};

setInterval("refreshPortlet()", 120000);

It works fine and the portlet refreshes, but the problem is that content of the portlet does not. I tried to clear the cache of the portlet with WebCachePoolUtil:

function refreshPortlet() {
    WebCachePoolUtil.remove("SOME_KEY");
    Liferay.Portlet.refresh("SOME_KEY")
};

setInterval("refreshPortlet()", 120000);

But now the function does not execute at all. Any hints?

Thanks in advance, Stjepko

WebCachePoolUtil is a Java class, thus not available on the JS side. The reason the method is not executing is that it's running into the unavailability of that class.

If you want to execute browser-side code like you did, you'd need to identify where caching is done - eg on the browser or on the server. Observe your Developer Tool's.network tab and inspect what's going across the wire.

Depending on the portlet that you're trying to refresh - specifically if it's a custom portlet - I'd recommend to implement Ajax explicitly and refresh either from a REST API or through the portlet's serveResource method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM