Loading page animation while JSF page is being loaded
jmsjrDec 4 2012 — edited Jan 29 2013JSF 2.1
Mojarra 2.1.7
JBoss 7.1.1
The backing bean on my JSF page(s) are view-scoped, and during the initial request, the backing bean's @PostConstructor method may take some time to return as it is calling external systems that are outside of my control. Thus, during the RENDER_RESPONSE phase of the initial request to the JSF page, it may take, on average, 3 to 5 seconds to return ( sometimes longer than that .... which again, is outside of my control ). While this is happening, the page rendered is of course blank as the response has not been written yet.
Naturally, I am thinking of a way to show an animated loading image.
1) I have seen suggestions of using a4j:status and a4j:region, but these are only valid for Ajax requests, while what I need is something that I can use during the initial request ( not a post back ), of a JSF lifecycle.
2) Suggestions of using two HTML divs... one DIV shows the animated image while the other DIV wraps the real content, but is initially hidden. Then use window.onload() to swap the style of the two DIVs so that the DIV wrapping the real content becomes visible while the DIV wrapping the animated image becomes hidden.
But then again ... these DIVs will NOT be written to the response yet as I am still in RENDER_RESPONSE phase.
The only thing that I can think of is to:
3) Create another page whose sole purpose is to show the animated image, then somehow immediately forward the request to the real page. The animated image on the first page will hopefully continue animating until the final page is rendered.
What have you guys done ?