by Stuart Greaves >> Tue, 15 Dec 1998 23:10:33 GMT
Ever wanted to automatically refresh (every 5 seconds, say) a JADE-generated form in a web browser environment?
Why would you want to do that?
Perhaps I should start at the beginning. Let's say you have an application that you'd like to deploy to both native JADE client and to a web browser. That's the way of the future! Assume it's a largish database, and there's a big report you need to generate at month-end which takes a half-hour to summarise to a single page of "print preview" output (sounds like a candidate for serverExecution, but that's another story...).
How do you monitor the progress while it's generating? On a native JADE client, this is pretty easy. The simplest method might be to just provide a standard progress bar control.. 93%..94%.. and make the user wait...
The web uses a Post/Response model that isn't very tolerant of interruptions. A subsequent request overrides the previous one. So on a dumb old web browser (IE4 I used in my case), there are a whole new set of issues for this example.
(1) You can't easily provide this percentage in an unsolicited manner. (2) because of this, there's a good chance your user is going to get a little bored or start to think the machine is doing *nothing*, and consequently start clicking buttons, such as the browser 'Back'. Such an action will not prevent the generation of your report, but it WILL prevent the report being supplied back to the browser when it's eventually prepared! So there's a high chance that the user will never see this report.
You'll all be aware of this phenomenon - when you initiate a web request, but don't wait for the reponse... instead you surf off to a more interesting site. In this case, you never get the original request's response, although at the server side it has probably continued to process it (a sad waste of processor cycles, to the sound of their network administrator's knashing teeth).
So, one approach (certainly not the only one) I used is this :
Start the 'report summarisation' task as a separate process on the same node (I used the 'startAppMethod' method of the Application class), and have it periodically update a new sharedTransient 'control' object as to its progress. Then introduce a new client form that reflects this status in the control object.
The browser-based user requests their report, and immediately this 'status' form is displayed. He/she can refresh this form (via a button provided) to get an updated picture of how the report generation is going.
He/she can also request cancellation of the report or, when it's finally ready for display, request the presentation of the report. As it's now been summarised, this only takes a matter of seconds. Then, using the browser's Print capability, obtain a physical report on their local printer that looks exactly like the one a native JADE client might have printed.
OK, so this all works - and it's not a bad solution because
(a) user now knows what's going on
(b) user is free to do other processing (excluding processing that would affect the report!) while the report is being generated, as a separate process is generating it
(c) user cannot accidentally *lose* the report. (Simple code was introduced that requires the user to explicitly Cancel or View the report before they can initiate another one.)
But my first problem was this... How to refresh the 'status' form automatically in the web browser? The user stares at a screen showing 3% complete, then finally clicks 'refresh' to see that it's actually 100% ready for printing. So I added a little WebHTML control to the status form. It contained only this simple HTML fragment
<meta http-equiv="Refresh" content="5">
which means "refresh this page automatically every 5 seconds". You'll be familiar with something very similar on the www.jade.co.nz web site, which redirects you to news.jadeworld.com, viz:
<meta http-equiv="Refresh" content="5; URL=news.jadeworld.com">
I didn't expect it to work because these 'meta' tags normally go in the <HEAD> section of a web page, not in the <BODY> where they will necessarily be placed by the jadehttp.dll program.
But it does work... ALMOST in a useable fashion!
Meta-tag redirections to the same page bring up the annoying and familiar message "Repost Form Data?" which I'd like to get rid of. Now you've read the whole story, my
Question #1
is.. Does anyone know how to turn the "Repost" prompt message off (in IE4 and/or other popular browsers like Nav.4)?? INI file setting? Registry?
Question #2
Redirections to *another* page or URL do not incurr this boring message. So one solution would be to give the full URL of the *current* page.. such a redirection would need to contain all the user session and object information, and would look a bit like this ....
<meta http-equiv="Refresh" content="5; URL=http://143.96.xx.xx/jade/jadehttp.dll?W ... orm/2113.3 &_pid=5&session=32a9acd8706bbaaa&17935.60=17935.60">
This data should be available as Web Server Environment variables (and it's already embedded within the web page's hidden form fields), but my question #2 is.... how does one access these variables within JADE so one can update the webHTML control accordingly? Anyone tried this?
Thanks for reading - you've been very patient!
Stuart Greaves
JADE Consultant
Sydney