Tuesday August 12, 2008
JSF - making sure your JSF pages load prior to calling JavaScript methods
Here's a quick note, but I found it very useful when it came to testing FireFox 3 and/or IE 8:
<![CDATA[
function OnLoad() {
var ignoreMe = document.body.offsetWidth;
if (ignoreMe == null) {
return setTimeout('OnLoad();', 10);
}
parent.leftFrame.location.href = "/faces/NavigationPage.jsp";
}
]]>
Then I add the javascript onLoad method to the JSF body tag (onLoad="OnLoad()") for example:
<webuijsf:body binding="#{com$FirstPage.body1}" id="body1" onLoad="OnLoad();" style="-rave-layout: grid">
That's it, this simple onLoad event makes sure the document has a page width set, if it doesn't I use the timeout method to re-call the OnLoad event and try again.
Posted at 08:08PM Aug 12, 2008 by Chris Fleischmann in GlassFish | Comments[0]