Auto re-freshing JADE forms in a browser environment

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Auto re-freshing JADE forms in a browser environment

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:11 pm

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

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Auto re-freshing JADE forms in a browser environment

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:11 pm

by John Eyers >> Wed, 16 Dec 1998 20:49:56 GMT
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?


The Jade web site code does this in a method on a form to do:
str := "jadehttp.dll?" & app.name & "&JADEFORM=" & self.name & "/" & self.getOidString &
"&session=" & currentSession.getEncryptedSessionId & "&" & myButton.getOidString & "=myButton";
then use str in the url above. This doesn't do the "pid=" but it doesn't seem to need it. If you want it, I think it is just "pid=" & currentSession.sessionId.

where myButton is a button on the form and getEncryptedSessionId is a method on your
WebSession class which just returns _encryptedSessionId.

This code will cause the button click event to be done. If you don't want this, use myLabel instead or try leaving it out and stopping at the encrypted session id.

John Eyers

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Auto re-freshing JADE forms in a browser environment

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:11 pm

by Stuart Greaves >> Mon, 21 Dec 1998 1:51:43 GMT

This works well. Note that the parameters specified in the <meta> tag override those parameters of the same name that JADE has supplied in hidden text fields at the top of the form, but it also seems any additional parameters in the hidden fields will be included too in the http refresh 'post'.

This is why you don't need to specify the "pid=" Session ID value... because it IS specified in the hidden fields at the top of the form, so it will be included.

And you're also right in suggesting that the 'myButton' you refer to, is not essential.

So, to summarise the simplest case : in JADE 4.0 and 4.1, if you want to make a JADE web form automatically refresh itself every 30 seconds, introduce a webHTML control thus:

webHTML1.text := '<meta http-equiv="Refresh" content=30;URL=jadehttp.dll?' & app.name
& '&JADEFORM=' & self.name & '/' & self.getOidString
& '&session=' & currentSession.getEncryptedSessionId
& '>';

Thanks to John Eyers and Martin Sperring for their help.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Auto re-freshing JADE forms in a browser environment

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:11 pm

by Dean Cooper >> Mon, 24 May 1999 23:10:06 GMT
So, to summarise the simplest case : in JADE 4.0 and 4.1, if you want to make a JADE web form automatically refresh itself every 30 seconds, introduce a webHTML control thus:

webHTML1.text := '<meta http-equiv="Refresh" content=30;URL=jadehttp.dll?' & app.name
& '&JADEFORM=' & self.name & '/' & self.getOidString
& '&session=' & currentSession.getEncryptedSessionId
& '>';

Except that (as per the example in John's posting) everything between 'content=' and the closing '>' needs to be enclosed in double quotes, ie:
webHTML1.text := '<meta http-equiv="Refresh" content="30;URL=jadehttp.dll?' & app.name
& '&JADEFORM=' & self.name & '/' & self.getOidString
& '&session=' & currentSession.getEncryptedSessionId & '">';

Dean.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Auto re-freshing JADE forms in a browser environment

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:11 pm

by kiwon >> Thu, 18 May 2000 3:54:16 GMT

Using javascript method can be a another idea..

this method show actyalTime on Web Browser Auto refreshed..

if you have interest please check out this... ===================================

load() updating;

vars

txt : String;begin

txt := "'http://server/JadeHTS/jadehttp.dll?" & app.name & "&JADEFORM=" & self.name & "/" & self.getOidString & "&session=" & currentSession.getEncryptedSessionId & "'";
webHTML1.text := '<SCRIPT LANGUAGE="JavaScript"> setTimeout("location.reload()", 3000); </SCRIPT>';
labelTime.caption := app.actualTime().String;
end

======================================

have a nice day~ =^^=


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 0 guests