掲示板

RE: Portlet: What does ajaxable really do?

13年前 に Thierry Ciot によって更新されました。

Portlet: What does ajaxable really do?

New Member 投稿: 3 参加年月日: 10/07/26 最新の投稿
From the DTD: "The default value of ajaxable is true. If set to false, then this portlet can never be displayed via Ajax."

When is a porlet displayed via ajax?

From this post "...when a portlet is not ajaxable, it is rendered together with the page, which means that if the portlet takes a long time to get it's data from a DB the whole page is taking long to load. But having it ajaxable, the page is being loaded directly and the content of the portlet is retrieved using ajax and added to the page after having received the portlet content."

I experimented with 2 portlets and I don't see this behavior at all. One portlet JSP takes a timestamp, calls Thread.sleep for 5s then takes another timestamp.
The other simply prints a timestamp.
The entire page takes > 5s to start rendering and both portlets appear to be rendered at the same time visually and the timestamps in both portlets seem to indicate the same.

Additionally, I don't see an ajax request in firebug.

If anybody could shed some lights on this, that would be great.

Thanks.
thumbnail
13年前 に Nate Cavanaugh によって更新されました。

RE: Portlet: What does ajaxable really do?

Junior Member 投稿: 94 参加年月日: 06/11/27 最新の投稿
Hi Thierry,
This portion of the DTD has always confused me a bit, and I believe it's because of the terminology used.

ajaxable defaults to true, and basically, it's to set whether a portlet *CAN* be loaded via ajax, not that it will be loaded via ajax.

In order to determine if it will be loaded via ajax, you need to set the render-weight to 0, like so:

<render-weight>0</render-weight>

If you set ajaxable to false, it overwrites render-weight to 1, because you're basically saying this portlet does not have the ability to be loaded via ajax, in other words, it's not ajaxable.

But all you really need to set is render-weight.

Hopefully that makes sense. You can read more here:
http://content.liferay.com/4.3/doc/devel/liferay_4_portlet_development_guide/multipage/ch02.html
(From 4.3, but the piece about render-weight and ajaxable still holds true).

Thanks Thierry,
13年前 に Srikanth Konjarla によって更新されました。

RE: Portlet: What does ajaxable really do?

Junior Member 投稿: 51 参加年月日: 08/10/25 最新の投稿
Nate,

I am referring to 5.2.3.

It seems that the LayoutAction class collects the portlets on a pages and runs "PortalUtil.renderPortlet()" for each portlet serially and aggregates the Markup. This suggests that the server side, the portlets on a Page are processed serially. However, the parallel rendering is achieved by setting "render-weight" to "0" and subsequently, the browser would render the portlet making Ajax call.

Snippet from PortletColumnLogic.java. Check out the for loop that goes through each portlet in a column.

for (int i = 0; i &lt; portlets.size(); i++) {
			Portlet portlet = portlets.get(i);

			String queryString = null;
			Integer columnPos = new Integer(i);
			Integer columnCount = new Integer(portlets.size());
			String path = null;

			if (_parallelRenderEnable) {
				path = "/html/portal/load_render_portlet.jsp";

				if (portlet.getRenderWeight() &gt;= 1) {
					_portletsMap.put(
						portlet,
						new Object[] {
							queryString, columnId, columnPos, columnCount
						});
				}
			}

			RuntimePortletUtil.processPortlet(
				sb, _servletContext, _request, _response, portlet, queryString,
				columnId, columnPos, columnCount, path);
		}


Refer to the LEP "http://issues.liferay.com/browse/LEP-209". The issue description says,

"If there are 10 portlets on a page to be rendered (no caching), and each portlet takes one second to execute its render() method, Liferay will take 10 seconds to render the page, due to the serial execution of each render() method. If the execution times are independent and the portlets are not constrained or synchronized on a common resource, the page could be rendered in one second (plus aggregation time) through parallel dispatch of render() execution."

Which kinda suggests that parallel dispatching of portlets is being worked out. But, as I stated earlier, portlets' markup is being fetched per column, per portlet of a layout.

Please comment.

Thanks
thumbnail
13年前 に Minhchau Dang によって更新されました。

RE: Portlet: What does ajaxable really do?

Liferay Master 投稿: 598 参加年月日: 07/10/22 最新の投稿
Srikanth Konjarla:
It seems that the LayoutAction class collects the portlets on a pages and runs "PortalUtil.renderPortlet()" for each portlet serially and aggregates the Markup. This suggests that the server side, the portlets on a Page are processed serially.

For ajaxable render weight 0 portlets, /html/portal/load_render_portlet.jsp doesn't actually call the render method of the portlet in question. Instead, Liferay renders the portlet with the portlet wrapper containers and adds some Javascript which makes an AJAX request for the portlet content, and the URL used by the AJAX request then calls the render method of the portlet.

That's why the property added in LEP-1427 is 'ajaxable' -- because if your portlet cannot be rendered using an asynchronous Javascript request in all browsers you wish to support in your Liferay installation (for example, many legacy browsers had problems loading Javascript), you should set the property to false and refactor your own code to speed up the render phase.
13年前 に Srikanth Konjarla によって更新されました。

RE: Portlet: What does ajaxable really do?

Junior Member 投稿: 51 参加年月日: 08/10/25 最新の投稿
Indeed. It applies to only portlets whose render-weight is set to "0". For all other portlets, the server side processing is still sequential. For example, if there are 4 portlets on a page in two columns and one portlet from each column has "render-weight" set to "0". To determine if a portlet's render method to be called however, the page (Layout) is processed sequentially. My point is that regardless of render weight value, each Layout's portlets are processed sequentially to determine the method to fetch the markup of individual portlet. This goes back to the old LEP as I have mentioned in my previous post.

Refer to the LEP "http://issues.liferay.com/browse/LEP-209". The issue description says,

"If there are 10 portlets on a page to be rendered (no caching), and each portlet takes one second to execute its render() method, Liferay will take 10 seconds to render the page, due to the serial execution of each render() method. If the execution times are independent and the portlets are not constrained or synchronized on a common resource, the page could be rendered in one second (plus aggregation time) through parallel dispatch of render() execution."


I guess the comment still stands correct in the sense that portlet information is processed in sequence, except that the ajaxed portlets' render method is not called. By setting the render weight to "0", the rendering of portlet is deferred to the browser and hence parallel rendering is achieved.

So, if we need to achieve a complete parallel rendering of a page, then mark all portlets' render-weight to "0" where possible.