Niks
Niks

Reputation: 4832

Loading data after a JSF page has completed rendering

I'm using Richfaces 4 and Mojarra 2.0.4. So I'll be glad if the answer is specific to Richfaces 4 framework :)

I understand that the JSF components are processed at the server side. Some of my pages are really data centric. So when I load that page (eg: inside a richTab with switchType ajax), it takes a lot of time for my bean to execute the method marked with @PostConstruct to execute and fetch data. And hence the time period between user clicking on the tab's header and actual page rendering is quite large, a really bad user experience. I've implemented lazy loading for the dataTables in the page but that still doesn't optimize my page load time since @PostConstruct is still there.

Is there anyway I can load the page first and THEN fetch the data with ajax and update the page? This loading time is really annoying for the user.Any help appreciated :)

PS: I thought of using the oncomplete and onbeforedomupdate client side events of rich:tab and call ajax functions declared with a4j:function. But it seems that these events are fired before the page is actually switched.

Upvotes: 0

Views: 3939

Answers (1)

niksvp
niksvp

Reputation: 5563

use onload event of <body> tag in html along with <a4j:jsFunction>

If you still feel your page is not rendering completely before the method called then use setTimeout('a4jfunctionName',10) javascript function in onload to complete the rendering first.

Upvotes: 1

Related Questions