FAQ

[Struts-user] Displaying "Please Wait" message

Frank W. Zammetti
Dec 10, 2008 at 12:07 am

RudyG wrote:
function splashScreen()
{
document.write("<p
style='color:black;background-color:aqua;text-align:center;margin:25% 25%
10% 25%;border: medium double black;'>Processing Data.<br>Please
Wait.</p>");
document.forms[0].submit();
return true;
}
Put an alert("test"); in place of your submit() line there... does the
alert show up? I just tried in both FF and IE and in both cases it
does... this indicates to me that it's the reference to the form that's
not working. So, try alert(document.forms[0]); and make sure you're
getting the object you expect. I actually expected the alert() to NOT
work because I figured the document.write() call was overwriting your
page, which would have made sense, but it appears document.write()
actually appends to the document. I wouldn't swear to that, but that's
what seems to be the case given my test.

Anyway, as others have said, that's isn't the best approach anyway.
Doing document.write() after the page has loaded is usually a good way
to get yourself into trouble. I suggest instead doing something like this:

<body>
<div style="width:100%;height:100%;display:none;"
id="pleaseWait">Please wait</div>
<div style="width:100%;height:100%;" id="myContents">
<!-- Everything else on your page goes here, including... -->
<input type="button"
onClick="document.getElementById('myConent').style.display='none';document.getElementById('pleaseWait').display='block';">
</div>
</body>

You'll probably want to play some CSS tricks (or table tricks, if you
don't mind the ridicule) to center the please wait message, which I
assume you'd prefer.

Also keep in mind with all the suggestions so far: what happens if the
call to the server takes too long, or doesn't work as expected? Is
there a graceful way for the user to recover? Probably not, and maybe
you can live with that, otherwise you might want to do something fancier
(possibly a "click me to abort" link below please wait, or a timeout()
that fires after X period of time and redirects to some "oops, the
server's borked" page).

hth,
Frank

--
Frank W. Zammetti
Author of "Practical Dojo Projects"
and "Practical DWR 2 Projects"
and "Practical JavaScript, DOM Scripting and Ajax Projects"
and "Practical Ajax Projects With Java Technology"
(For info: apress.com/book/search?searchterm=zammetti&act=search)
My "look ma, I have a blog too!" blog: zammetti.com/blog


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
reply

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions