CGI: Help with "loading" message while processing.

C

corky

Using Perl 5.6.0. I need to temporarily show a message while I process
in the background. The process calls an OLE component which sets a
value in the user's cookie.

The DisplaySecSubmit sub calls my "please wait" page which is static.
The GetSecureModels sub runs the OLE process and sets the cookie.
The DisplaySubmit sub displays a new page which uses the cookie which
was just set.

Here is where it starts:

elsif ($FORM{'FUNC'} eq 'DISP_SEC_SUBMIT')
{&RightViolation($CREATE_RIGHT) if (($createRight == 0) &&
($a_createRight == 0));
&DisplaySecSubmit();
&GetSecureModels();
&DisplaySubmit();
}

use Win32::OLE;
use DBI;
use DBD::ODBC;


sub GetSecureModels{
if (length($trainedOn) < 1){
$dbh = DBI->connect("dbi:ODBC:support", exsu, exsupwd)|| die "Can't
connect !!: $DBI::errstr";
$dbh -> {RaiseError} = 1;
$stmt = "SELECT DISTINCT CTI_MODEL, MODEL FROM MODEL_LOOKUP WHERE
STATUS = 'ACTIVE' AND CLASS_FAMILY IN (SELECT DISTINCT FAMILY FROM
MODEL_FAMILY) ORDER BY MODEL;";
$sth = $dbh->prepare($stmt)|| die "Error on prepare $DBI::errstr";
$sth->execute()|| die "Error on Execute $DBI::errstr";
while (@row = $sth->fetchrow_array) {
my $server = Win32::OLE->new('auth.caller','Quit');
$server->{Model} = $row[0];
$server->{NSSGID} = $userID;
my $trainstat = $server->{Verify};
if ($trainstat ne -1 ) {
push @trainedOn , $row[1];
}
}
$trainedOn = join ',', @trainedOn;
print "Content-type: text/html; charset=utf-8\n";
&SetCompressedCookies('MODELS','trainedOn', $trainedOn);
print "\n";
}
}


sub DisplaySecSubmit{
&set_submit_strings();
&EchoFile($HTML_PATH, "traincheck.htm");
}

My problem is that it seems as though each individual CGI call will
only return a single page of output. For example, I show my "please
wait" message while I'm processing and when processing is done the
results are appended to the "please wait" message instead of replacing
it.

Another problem is that the cookie stuff shows in the browser too.

Is there any way to flush or start with a clear screen? Can I run the
process on a different thread? Can I use refreshes to handle this? Or
should I use a combination of approaches?

I only use Perl once a year or so as necessary, and as a consequence
this may be a simple problem with a simple answer, so please forgive
me.

Thanks in advance for any help,

Corky
 
T

Tom

Using Perl 5.6.0. I need to temporarily show a message while I process
in the background. The process calls an OLE component which sets a
value in the user's cookie.

The DisplaySecSubmit sub calls my "please wait" page which is static.
The GetSecureModels sub runs the OLE process and sets the cookie.
The DisplaySubmit sub displays a new page which uses the cookie which
was just set.

Here is where it starts:

elsif ($FORM{'FUNC'} eq 'DISP_SEC_SUBMIT')
{&RightViolation($CREATE_RIGHT) if (($createRight == 0) &&
($a_createRight == 0));
&DisplaySecSubmit();
&GetSecureModels();
&DisplaySubmit();
}

use Win32::OLE;
use DBI;
use DBD::ODBC;


sub GetSecureModels{
if (length($trainedOn) < 1){
$dbh = DBI->connect("dbi:ODBC:support", exsu, exsupwd)|| die "Can't
connect !!: $DBI::errstr";
$dbh -> {RaiseError} = 1;
$stmt = "SELECT DISTINCT CTI_MODEL, MODEL FROM MODEL_LOOKUP WHERE
STATUS = 'ACTIVE' AND CLASS_FAMILY IN (SELECT DISTINCT FAMILY FROM
MODEL_FAMILY) ORDER BY MODEL;";
$sth = $dbh->prepare($stmt)|| die "Error on prepare $DBI::errstr";
$sth->execute()|| die "Error on Execute $DBI::errstr";
while (@row = $sth->fetchrow_array) {
my $server = Win32::OLE->new('auth.caller','Quit');
$server->{Model} = $row[0];
$server->{NSSGID} = $userID;
my $trainstat = $server->{Verify};
if ($trainstat ne -1 ) {
push @trainedOn , $row[1];
}
}
$trainedOn = join ',', @trainedOn;
print "Content-type: text/html; charset=utf-8\n";
&SetCompressedCookies('MODELS','trainedOn', $trainedOn);
print "\n";
}
}


sub DisplaySecSubmit{
&set_submit_strings();
&EchoFile($HTML_PATH, "traincheck.htm");
}

My problem is that it seems as though each individual CGI call will
only return a single page of output. For example, I show my "please
wait" message while I'm processing and when processing is done the
results are appended to the "please wait" message instead of replacing
it.

Another problem is that the cookie stuff shows in the browser too.

Is there any way to flush or start with a clear screen? Can I run the
process on a different thread? Can I use refreshes to handle this? Or
should I use a combination of approaches?

You can open multiple windows by simply including a JavaScript open
function in you HTML document. For example, when you submit the query
using the input form generated by the code below, the browser will
open a new window with your messages.

#!/usr/bin/perl -w

use strict;

use CGI qw:)standard);
print header("text/html");

if(param("DISP_SEC_SUBMIT"))
{
&DisplaySecSubmit();
&GetSecureModels();
exit;
}

my $script = "form.cgi";
print <<FORM;
</head><body onUnload='javascript:msg.window.close()'>
<script language='JavaScript'>
function wait()
{
msg = window.open("","msg","width=600,height=150");
msg.document.open("text/html");
msg.document.write("Please wait...");
return true;
}
var msg;
</script>

<h3>FORM TITLE...</h3>
<form method=post action=$script onSubmit='return wait()'>
<table><tr><th>SecureModels:<td><input name='DISP_SEC_SUBMIT'
value='SecureModels value...'>
<tr><td><input type=submit></table></form>

FORM

sub DisplaySecSubmit
{
print "DisplaySecSubmit...<p>";
my $trainedOn = "SELECT DISTINCT...";
&SetCompressedCookies('MODELS','trainedOn', $trainedOn);
sleep(2);
print "\n";
}

sub SetCompressedCookies
{
print "SetCompressedCookies...<p>ARGUMENTS: @_";
sleep(2);
}

sub GetSecureModels
{
I only use Perl once a year or so as necessary, and as a consequence
this may be a simple problem with a simple answer, so please forgive
me.

As you can see, the above solution is more of JavaScript than PERL. So
any follow-up should be directed to the appropriated group such as
comp.lang.javascript.

Tom
Ztml.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top