Search code examples
liferayportlet

How to render a portlet without rendering whole page. Liferay


I have two portlets at the same page. Portlet A does a very quick task, and Portlet B does a very slow task. Portlet B reads a parameter from A. If I make a change on A (with RenderURL), Liferay renders whole page (including slow Portlet B). How can I say Liferay to render only Portlet A and not Portlet B?


Solution

  • the renderURL will always point to the whole page. If you go "manual", e.g. without other framework's help, you'll need to utilize the resourceURL and refresh your portlet's content with Ajax.

    Another option is to declare your slow portlet B as asynchronous ("ajaxable") and cache the output so that you don't have to constantly do expensive render operations. The ajaxable option is available in liferay-portlet.xml and is documented for that file. The RSS portlet (Liferay-OOTB) is configured like this as it might take a while until this portlet has collected all of its RSS feeds and can render. This might be a good blueprint for your required changes.