Batch/Block-Mode updates to Select Lists - How to avoid?

S

scripts.contact

The problem is that none of the rows I'm inserting appear on the screen
until I have RETURNed from my function; so If it ended up being 1000 rows
then the user sees nothing until they're *all* processed :-( Is this an
IE6-only thing? Does it happen with Version 7 or with other browsers? This
is disgusting!

workaround-

function something(){

// add option here

if(someCondition)setTimeout(something,1)
}


or if you want a little fast-

function something(){

for(var x=0;someCondition;x++){
// addOption here

if(x=20 && someCondition){setTimeout(something,1);break}
}

}

^^ it will update the GUI after every 20 options.
 
R

Richard Maher

Hi,

I have this Applet-hosted Socket connection to my server and in an
ONevent/function I am retrieving all these lovely rows from the server and
inserting them into the Select-List. (The on screen appearance of the Select
List grows for the first 5 rows then the scroll bar appears if there's
more). So far so good. . .

The problem is that none of the rows I'm inserting appear on the screen
until I have RETURNed from my function; so If it ended up being 1000 rows
then the user sees nothing until they're *all* processed :-( Is this an
IE6-only thing? Does it happen with Version 7 or with other browsers? This
is disgusting!

Is there an option to set somewhere?

Do I have to hack/force some sort of event (with coresponding ONfunction)
and then RETURN from my function and have the ensuing function call me back
and repeat till eof? Yuck.

All I want to do is see my rows grow and counter increment in the
select-list (or table) as they appear; is that really too much to ask? Is
IBM3270 emulation crap really as far as we've got?

Regards Richard Maher

PS. The funny thing (or glimmer of hope!) is, when I loop till
list.options.length = 0 {list.remove(list.options[0])} I see the rows
disappear before my eyes. (Admittedly when i set the list.size = 1 it does
not take immediate effect but we're getting somewhere right? (I set it to 1
'cos I re-insert a "header row" at [0]))
 
R

Richard Maher

Hi,
if(someCondition)setTimeout(something,1)

Doesn't look like there's anyway around it does there :-( I suppose
fireEvent and whatever the FF version is is probably the correct thing to
do, rather fudge a setNoTimeout() but it's just a bit sad that the Options
can be removed on demand but just not inserted :-(

Thanks anway.

Cheers Richard Maher

PS. There's noone out there that's tried this with a Table rather than a
Select List is there?
 
A

ASM

Richard Maher a écrit :
Hi,

I have this Applet-hosted Socket connection to my server and in an
ONevent/function I am retrieving all these lovely rows from the server and
inserting them into the Select-List. (The on screen appearance of the Select
List grows for the first 5 rows then the scroll bar appears if there's
more). So far so good. . .

The problem is that none of the rows I'm inserting appear on the screen
until I have RETURNed from my function; so If it ended up being 1000 rows
then the user sees nothing until they're *all* processed :-( Is this an
IE6-only thing? Does it happen with Version 7 or with other browsers? This
is disgusting!

IE is very very lazy with tables
(Firefox will do the job in less than 1 or 2 seconds)
Is there an option to set somewhere?

to set what ?

you didn't show your function,
how to say what to set or to modify or ...
Do I have to hack/force some sort of event (with coresponding ONfunction)
and then RETURN from my function and have the ensuing function call me back
and repeat till eof? Yuck.

Probably, if you want *to see* your table growing,
you'll have to code for that feature ? no ?

mini example :

<html>
<script type="text/javascript">
// array of "lovely rows"
var R = [12,11,10,9,'c','d','e','one','two','tree'];

function insertMyRows(idx) {
var T = document.getElementById('myTable').insertRow(idx+1);
var D = document.createElement('TD');
D.innerHTML = R[idx];
T.appendChild(D);
}
function feedTable(timer) {
var L = R.length;
var i=0;
while(i<L) {
setTimeout('insertMyRows('+i+')',timer*i);
i++;
}
}
</script>
<form action="javascript:feedTable(document.form[0][0].value)">
Delay to see table growing :
<input onclick="this.select();" value="200">
and hit [Enter];
</form>
<a href="#" onclick="feedTable(200);return false;">grow table</a>
<table id="myTable">
<tr><th>tests</th></tr>
</table>
All I want to do is see my rows grow and counter increment in the
select-list (or table) as they appear; is that really too much to ask? Is
IBM3270 emulation crap really as far as we've got?

Regards Richard Maher

PS. The funny thing (or glimmer of hope!) is, when I loop till
list.options.length = 0 {list.remove(list.options[0])} I see the rows
disappear before my eyes. (Admittedly when i set the list.size = 1 it does
not take immediate effect but we're getting somewhere right? (I set it to 1
'cos I re-insert a "header row" at [0]))

can we see an example on line ?
(I'll not make myself an example of what I understand you're telling)

can you precise : with which navigator(s)
 
A

ASM

Richard Maher a écrit :
the Options
can be removed on demand but just not inserted :-(

You cant' add options to a select ?

var o = new Option(text, value);
var S = document.myForm.mySelect
S.options[S.length] = o;
 
E

Evertjan.

ASM wrote on 17 mrt 2007 in comp.lang.javascript:
Richard Maher a ‚crit :
the Options
can be removed on demand but just not inserted :-(

You cant' add options to a select ?

var o = new Option(text, value);
var S = document.myForm.mySelect
S.options[S.length] = o;

No, you can append or overwrite, not insert,
unless you rewrite the whole select again:

<form name=myForm>
<select name=mySelect>
</select>
</form>

<script type='text/javascript'>

var S = document.forms['myForm'].elements['mySelect'];

for (var i=1;i<11;i++)
S.options[S.length] = new Option('text '+i, 'value');

S.options[3] = new Option('text overwrites 4', 'value');

</script>
 
E

Evertjan.

Evertjan. wrote on 17 mrt 2007 in comp.lang.javascript:
ASM wrote on 17 mrt 2007 in comp.lang.javascript:
Richard Maher a ‚crit :
the Options
can be removed on demand but just not inserted :-(

You cant' add options to a select ?

var o = new Option(text, value);
var S = document.myForm.mySelect
S.options[S.length] = o;

No, you can append or overwrite, not insert,
unless you rewrite the whole select again:

<form name=myForm>
<select name=mySelect>
</select>
</form>

<script type='text/javascript'>

var S = document.forms['myForm'].elements['mySelect'];

for (var i=1;i<11;i++)
S.options[S.length] = new Option('text '+i, 'value');

S.options[3] = new Option('text overwrites 4', 'value');

</script>

Insertion can be done by this elaborate way:

<form name=myForm>
<select name=mySelect>
</select>
</form>

<script type='text/javascript'>

var S = document.forms['myForm'].elements['mySelect'];
for (var i=0;i<9;i++)
S.options = new Option('text '+i, 'value');


var n = 3; // inserting at n
var insert = "inserted text"

for (var i=S.length;i>n;i--) {
x = S.options[i-1];
S.options = new Option(x.text, x.value);
};
S.options[n] = new Option(insert, 'thevalue');

</script>
 
A

ASM

Evertjan. a écrit :
ASM wrote on 17 mrt 2007 in comp.lang.javascript:
Richard Maher a ‚crit :
the Options
can be removed on demand but just not inserted :-(
You cant' add options to a select ?

var o = new Option(text, value);
var S = document.myForm.mySelect
S.options[S.length] = o;

No, you can append or overwrite, not insert,
unless you rewrite the whole select again:


.... ? not exactly 'rewrite' nor 'whole'

<form name=myForm>
<select name=mySelect>
</select>
</form>

<script type='text/javascript'>

var S = document.forms['myForm'].elements['mySelect'];
// create and append options
for (var i=1;i<11;i++)
S.options[S.length] = new Option('text '+i, 'value');
// insert a new option (ie: on row 5)
for(var i=S.length; i>5; i--)
S.options = new Option(S.options[i-1].text,S.options[i-1].value);
S.options[5] = new Option('new text 5', 'value');

</script>
 
A

ASM

Evertjan. a écrit :
Insertion can be done by this elaborate way:

Ha! tout de même ! :)

and it is not so "elaborate" ...
(comparatively to insert a new row in a table)
 
R

Richard Maher

Hi Stephane,

Thanks for the reply.
IE is very very lazy with tables
(Firefox will do the job in less than 1 or 2 seconds)

Not if the data isn't coming back in 1 to 2 seconds. Locking? Pregnant
pauses? Volume? (First 10 rows are quick followed a stutter on the network
then a burst; who knows?)

Is the anorexic-client strategy the prevailing mind-set everywhere in the
HTML and Javascript world?
to set what ?

To turn off bloody batch-updating! When I change the screen I want the
screen to change. Am I not saying this right?

If you see the html below where I say: - "document.getjobs.rec_count.value
= rc;" I want the record counter to click-over on the screen (*as the rows
are being retrieved*) Yes, this is live-TV not a delayed telecast :)

I want the scroll-bar to diminish on my select-list, I want the user to
receive feed-back (and be empowered :), I don't want to have to simulate
recurrsion just so as to surrender the thread long enough to repaint my
3270. (But it looks like the quasi-event inducing timer is the only way to
go?)

But I'd still like to know why: -

while (selectRef.options.length > 0)
{
selectRef.remove(selectRef.options[0]);
}
_gets reflected on the screen immediately but: -

selectRef.options[selectRef.options.length] = new Option (jobMsg);

_does not?
can we see an example on line ?
(I'll not make myself an example of what I understand you're telling)

It's a work-in-progress and I'm not geared-up for it online, but the code
(and my knowledge of JS/HTML :) is rather simple so I've attached it below.
can you precise : with which navigator(s)

IE6 on Windows2000.

Thanks again.

Cheers Richard Maher

queue_lookup.html (contains select list - job_list)
===================================================

<html>

<head>

<title>
Example Client for Tier3 demo queue-lookup server
Author: Richard Maher
</title>

<style>

h2
{
color: Turquoise;
}

p.credits
{
color: Turquoise;
}

.green_screen
{
color: Lime;
background-color: Black;
font-family: courier;
}

</style>

<script type="text/javascript">

function load()
{
chan =
parent.frames["cornucopiae"].document.getElementById("CornuCopiae");
}

var chan;

function enter(nextfield)
{
if (window.event && window.event.keyCode == 13)
{
nextfield.focus();
return false;
}
else
return true;
}

function num_only(numObj)
{
if (isNaN(numObj.value))
{
numObj.value = "";
alert("Numeric value required");
numObj.focus();
return false;
}
else
return true;
}

function job_lookup()
{
if (!num_only(document.getjobs.entry_number))
return false;

var recTypeLen = 2;
var recType = "";
var msgGetInfo = "10";
var jobInfo = "11";
var errorInfo = "00";

var zeroFill = "0000";
var maxRows = "9999";
var outPad = "";
var ok = true;

var selectRef = document.getjobs.job_list;
var msgEntry = "";

selectRef.options[0].selected=true;
var holdHdr = selectRef.options[0];

while (selectRef.options.length > 0)
{
selectRef.remove(selectRef.options[0]);
}
selectRef.options[0] = holdHdr
document.getjobs.job_list.size = 1;

msgEntry = document.getjobs.entry_number.value;
outPad = zeroFill.substring(0, (zeroFill.length - msgEntry.length));

chan.sendMessage(msgGetInfo.concat(outPad,msgEntry,maxRows));

if (chan.readMessage(recTypeLen) != recTypeLen)
{
alert ("Error receiving reply from server");
return false;
}
recType = chan.getString(0,recTypeLen);

if (recType == jobInfo)
{
ok = process_jobs();
}
else
{
if (recType == errorInfo)
{
ok = process_error();
}
else
{
alert ("Unknown message type " + recType);
return false;
}
}

if (!ok) return false;

document.getjobs.entry_number.focus();

return true;
}

function process_error()
{
document.getjobs.rec_count.value = 0;

var errMsgLen = 0;
var errLenLen = 3;
var alertMsg = "Error retrieving job entry information\n";

if (chan.readMessage() < errLenLen)
{
alert ("Error receiving Error Length from server");
return false;
}

errMsgLen = parseInt(chan.getString(0,errLenLen),10);
alertMsg = alertMsg + chan.getString(errLenLen,errMsgLen);
alert(alertMsg);

return true;
}

function process_jobs()
{
var recTypeLen = 2;
var recType = "";
var jobInfo = "11";
var eofInfo = "99";
var eofLen = 3;
var jobMsgLen = 109;
var jobMsg = "";
var rc = 1;
var eofInfo = "99";
var selectRef = document.getjobs.job_list;

for (;;)
{

document.getjobs.rec_count.value = rc;

rc = rc + 1;
if (rc < 6)
document.getjobs.job_list.size = rc;

if (chan.readMessage(jobMsgLen) != jobMsgLen)
{
alert ("Error receiving Job Information from server");
return false;
}

jobMsg = chan.getString(0,4) + "|" +
chan.getString(4,39) + "|" +
chan.getString(43,15) + "|" +
chan.getString(58,31) + "|" +
chan.getString(89,10) + "|" +
chan.getString(99,10);
selectRef.options[selectRef.options.length] = new Option (jobMsg);

if (chan.readMessage(recTypeLen) != recTypeLen)
{
alert ("Error receiving reply from server");
return false;
}

recType = chan.getString(0,recTypeLen);
if (recType != jobInfo)
break;
}

if (recType != eofInfo)
return false;

if (chan.readMessage(eofLen) != eofLen)
{
alert ("Error receiving reply from server");
return false;
}

return true;
}

</script>

</head>

<body onload="load()">

<h2>Example Client for Tier3 DEMO application server on VMS</h2><hr>

<form name="getjobs">

Enter Job Entry Number [Default is All jobs]:
<input
type="text"
onkeypress="return enter(document.getjobs.send)"
name="entry_number"
maxlength=4
size=4
dir="rtl"
/>

<input
type="button"
onmouseup="job_lookup()"
name="send"
value="Get Job Info."
/>

Jobs Found:
<input
type="text"
name="rec_count"
onchange="alert('change')"
readonly
value="0"
size=5
/>

<br /><br />

<select
name="job_list"
id="Job_list"
class="green_screen"
size=1>
<option
value="lovhdr"
selected=true
disable=trueNbr--Job-Name--------------------------------Job Status------Queue
Name----------------------Queue Type-Status----</option>
</select>

<br />

</form>

<div style="overflow:auto; height:180px;">
<p>
This is an example of a browser-based, html and JavaScript,
client interacting with a VMS hosted Tier3 Application Server
in a connection-oriented and context-rich Tier3 environment.<br /><br />

You would have noticed that, when this page was initially displayed,
you were immediately prompted for your VMS Username and Password.
Once authorization is successful your credentials, and an accompanying
Persona, are automatically made available to your 3GL User Action
Routines each time their Server Process is chosen to perform work on
behalf of the client. In this example, the user only gets to see those
Print and Batch jobs that they have privileges to view. You can find
the corresponding server code for this example (demo_uars.cob) in your
t3$examples directory.<br /><br />

The session and server connection are terminated when you change
web pages or refresh this page.
</p></div>

<hr>

<p class="credits">
"Tier3" is a registered trademark of Tier3 Software Ltd<br />
"CornuCopiae" is a trademark of Richard Maher
</p>

</body>
</html>

CornuCopiae.html - header with status info
==========================================

<html>

<head>

<title>
Example2 Sperate Cornucopiae control Frame
for Identification and status displays.
Author: Richard Maher
</title>

<style>

body
{
background-color: Turquoise;
color: Grey;
margin: 0;
padding: 0;
line-height: 0;
}

.cell1
{
font-family: Georgia;
font-size: 75%;
text-align: left;
width="33%";
}

.cell2
{
font-family: Georgia;
font-size: 150%;
font-weight: bold;
color: Black;
text-align: center;
width="34%";
}

.cell3
{
font-family: Georgia;
font-size: 75%;
text-align: right;
width="33%";
}

.revLeft
{
background-color: Grey;
color: Turquoise;
font-size: 75%;
font-weight: bold;
text-align: left;
}

.revRight
{
background-color: Grey;
color: Turquoise;
font-size: 75%;
font-weight: bold;
text-align: right;
}

</style>

<script type="text/javascript">

var chan;
var base;
var oneSec;
var oneMin;
var oneHour;
var oneDay;
var outDelta;
var intId;

function load()
{
chan = document.getElementById("CornuCopiae");
var username = chan.getUsername();
document.starship_ctrl.username.value=username;

oneSec = 1000;
oneMin = 60*oneSec;
oneHour= 60*oneMin;
oneDay = 24*oneHour;

base = chan.getConnectTime();
intId=self.setInterval("deltaClock()",1000);
}

function deltaClock()
{
var currDate = new Date();
var now = currDate.getTime();
var interval = (now - base);

var clockDays = Math.floor(interval / oneDay);
interval = interval - (clockDays * oneDay);

var clockHours = Math.floor(interval / oneHour);
interval = interval - (clockHours * oneHour);

var clockMins = Math.floor(interval / oneMin);
interval = interval - (clockMins * oneMin);

var clockSecs = Math.floor(interval / oneSec);
interval = interval - (clockSecs * oneSec);

outDelta = zPad(clockHours) + ":"
+ zPad(clockMins) + ":"
+ zPad(clockSecs) + " "
+ clockDays;

document.starship_ctrl.clock.value=outDelta;

}

function zPad(num)
{
if (num < 10)
{
num ="0" + num;
}
return num;
}

</script>

</head>

<body onload="load()">

<form name="starship_ctrl">

<table
border=0;
frame="void";
cellpadding="0";
cellspacing="0";
width="100%";
rules="none";
<tr
valign="middle";
<td
class="cell1";
valign="middle";
Username:
<input
name="username";
class="revLeft";
type="text";
size=10;
maxlength=10;
readonly="readonly";
/></td>

<td
class="cell2";
valign="middle";

<td
class="cell3";
valign="middle";
Connected:
<input
name="clock";
class="revRight";
type="text";
dir="rtl";
size=10;
maxlength=10;
readonly="readonly";
/></td>
</tr>

</table>

</form>

<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
width= "0" height= "0" name="CornuCopiae"
id="CornuCopiae">
<param name="archive" value="tier3.jar">
<param name="codebase"
value="http://1.2.3.6/">
<param name="code" value="CornuCopiae">
<param name="mayscript" value="yes">
<param name="scriptable" value="true">
<param name="name" value="CornuCopiae">
<param name="PORT" value="1024">
<param name="HOSTCHARSET" value="ISO-8859-1">
<param name="MAXBUF" value="512">
<param name="APPLICATION" value="DEMO">
</object>

</body>
</html>

Example2.html (I use two frames)
================================

<html>

<frameset rows="5%,*">

<frame
src="cornucopiae.html";
name="cornucopiae";
marginheight="0";
marginwidth="0";
frameborder="1";
noresize="noresize";
scrolling="no";
/>

<frame
src="";
name="queue_lookup";
frameborder="0";
noresize="noresize";
scrolling="auto";
/>

</frameset>

</html>


ASM said:
Richard Maher a écrit :
Hi,

I have this Applet-hosted Socket connection to my server and in an
ONevent/function I am retrieving all these lovely rows from the server and
inserting them into the Select-List. (The on screen appearance of the Select
List grows for the first 5 rows then the scroll bar appears if there's
more). So far so good. . .

The problem is that none of the rows I'm inserting appear on the screen
until I have RETURNed from my function; so If it ended up being 1000 rows
then the user sees nothing until they're *all* processed :-( Is this an
IE6-only thing? Does it happen with Version 7 or with other browsers? This
is disgusting!

IE is very very lazy with tables
(Firefox will do the job in less than 1 or 2 seconds)
Is there an option to set somewhere?

to set what ?

you didn't show your function,
how to say what to set or to modify or ...
Do I have to hack/force some sort of event (with coresponding ONfunction)
and then RETURN from my function and have the ensuing function call me back
and repeat till eof? Yuck.

Probably, if you want *to see* your table growing,
you'll have to code for that feature ? no ?

mini example :

<html>
<script type="text/javascript">
// array of "lovely rows"
var R = [12,11,10,9,'c','d','e','one','two','tree'];

function insertMyRows(idx) {
var T = document.getElementById('myTable').insertRow(idx+1);
var D = document.createElement('TD');
D.innerHTML = R[idx];
T.appendChild(D);
}
function feedTable(timer) {
var L = R.length;
var i=0;
while(i<L) {
setTimeout('insertMyRows('+i+')',timer*i);
i++;
}
}
</script>
<form action="javascript:feedTable(document.form[0][0].value)">
Delay to see table growing :
<input onclick="this.select();" value="200">
and hit [Enter];
</form>
<a href="#" onclick="feedTable(200);return false;">grow table</a>
<table id="myTable">
<tr><th>tests</th></tr>
</table>
All I want to do is see my rows grow and counter increment in the
select-list (or table) as they appear; is that really too much to ask? Is
IBM3270 emulation crap really as far as we've got?

Regards Richard Maher

PS. The funny thing (or glimmer of hope!) is, when I loop till
list.options.length = 0 {list.remove(list.options[0])} I see the rows
disappear before my eyes. (Admittedly when i set the list.size = 1 it does
not take immediate effect but we're getting somewhere right? (I set it to 1
'cos I re-insert a "header row" at [0]))

can we see an example on line ?
(I'll not make myself an example of what I understand you're telling)

can you precise : with which navigator(s)
 
A

ASM

Richard Maher a écrit :
Hi Stephane,

Salut Richard,

(... about tables ...)
Not if the data isn't coming back in 1 to 2 seconds.

Of course !
And that is not our problem since we can do anything about server's job
(in JavaScript client side)
Is the anorexic-client strategy the prevailing mind-set everywhere in the
HTML and Javascript world?

rien compris ...
To turn off bloody batch-updating! When I change the screen I want the
screen to change. Am I not saying this right?

You only try to change content of a select (if I well saw)

The alone action is :
chan.sendMessage(msgGetInfo.concat(outPad,msgEntry,maxRows));
that's to say to call an applet
(applet I don't know what it make)

How do we know this applet has received an answer ?
How do we explain to JS to wait this(theses) answer(s) ?

I think it would be better to call back 'CornuCopiae.html' in its frame
and it would be this frame which on loaded will fix the select

(no need ';' in end of lines : here we are in html code)

<html>

<frameset rows="5%,*">

<frame
src="cornucopiae.html"

onload = parent.queue_lookup.job_lookup();"

name="cornucopiae"
blah
/>

<frame
src=""
name="queue_lookup"
blah
/>

</frameset>

If you see the html below where I say: - "document.getjobs.rec_count.value
= rc;" I want the record counter to click-over on the screen (*as the rows
are being retrieved*) Yes, this is live-TV not a delayed telecast :)


selectRef.options = new Option( blah );
if(i<5) selectRef.size = (+i+1);

// to show the option just completed :
selectRef.options.selectedIndex = i;

the thread long enough to repaint my 3270.

Aren't we in 2007 ?
(But it looks like the quasi-event inducing timer is the only way to
go?)

You'l only need a timer routine if you want to see progress in the
select, else this select is completed in once time.
But I'd still like to know why: -

while (selectRef.options.length > 0)
{
selectRef.remove(selectRef.options[0]);
}
_gets reflected on the screen immediately but: -

selectRef.options[selectRef.options.length] = new Option (jobMsg);

_does not?

Both things you do are completely different :-(

At least compare similar features (empty the list) :

while(selectRef.options.length>0)
selectRef.remove(selectRef.options[0]);
and
selectRef.options.length = 0;
IE6 on Windows2000.

I can't test with that.
queue_lookup.html (contains select list - job_list)
===================================================

as I'vn't the applet ...
and as it is a little long to follow what is it supposed to do
(going up and/or down to search where is defined this or that)

For your main question :
you empty the select by DOM
and try to fill it up via old JS

and we don't know how you get datas (what to put in options)

function process_jobs()
{
var ... blah
var selectRef = document.getjobs.job_list;

for (;;) // <----- yes? for what and where ?
{
 
V

VK

I have this Applet-hosted Socket connection to my server and in an
ONevent/function I am retrieving all these lovely rows from the server and
inserting them into the Select-List. (The on screen appearance of the Select
List grows for the first 5 rows then the scroll bar appears if there's
more). So far so good. . .

The problem is that none of the rows I'm inserting appear on the screen
until I have RETURNed from my function; so If it ended up being 1000 rows
then the user sees nothing until they're *all* processed :-( Is this an
IE6-only thing? Does it happen with Version 7 or with other browsers? This
is disgusting!

Starting from the last question: yes, this behavior is by design, yes,
it is shared by all browsers. See my FAQ entry proposal at
Right, see the provisional FAQ entry at
http://groups.google.com/group/comp.lang.javascript/msg/b1470812c5e4d3b5
That is one of these things that makes me often think that the browser
market gets more and more open for a new yet unknown winner. Just like
dinosaurs were getting bigger and nastier by accelerating the same
proved stuff and then a lemur-like puny sent them all to the evolution
threshold. The Cold Standard Wars - logically followed the hot Browser
Wars - ended 7 March 2007 with the known W3C press-release. IMHO the
war years of 2004-2007 left developers equally sick of the Microsoft/
IE warm quagmire gripping - and from semantic/standard hop goblins of
the rivals. That is usually an indication of the development being
taken over by a 3rd force. At least in the society it goes that way.

Now on the subject:
It is not clear from your description how do you handle the server
data. Do you use your applet as a pipe, so on each new record arrived
from the server it calls javascript function for DOM update? Or do you
retrieve all server data first by your applet and then forward all
records to javascript for DOM update in loop?

Depending on that the most effective workaround can be suggested.
 
R

Richard Maher

Hi VK,

Thanks for the reply.
Starting from the last question: yes, this behavior is by design, yes,
it is shared by all browsers. See my FAQ entry proposal at
Right, see the provisional FAQ entry at
http://groups.google.com/group/comp.lang.javascript/msg/b1470812c5e4d3b5

Glad to see I'm not the only one who finds all this a tad dissappointing and
FWIW I agree with your thoughts on room for new players in the Browser world
(or at least a whole lot of scope for improvement with existing players)
I've pointed out before that I'm a newbie and don't know much about this
stuff, but I am impressed with what can be achieved for very little effort!
Rightly or wrongly, the browser *is* the user interface of choice for a lot
of applications, but if it is unable to perform simple stuff like this then
I can't see it ever getting over the "We do *real* GUIs in Java or VB.NET or
C# et al" attitude. Maybe they're right?

Anyway. . .
Now on the subject:
It is not clear from your description how do you handle the server
data. Do you use your applet as a pipe, so on each new record arrived
from the server it calls javascript function for DOM update? Or do you
retrieve all server data first by your applet and then forward all
records to javascript for DOM update in loop?

Although TCP/IP is stream oriented, in this (and many other examples) I deal
in records, or messages of pre-defined format and size. Here I'm retrieving
Batch/Printer Queue information from the server and send a "10" request
message in response to which I receive numerous "11" messages (one
Applet/Socket read per message) until an EOF message "99". Or if no matching
Jobs were found I'd get a "00" Error message with a 3-byte message length
"013" that gets translated to *eleven* 'cos some idiot decided that the JAVA
parseInt() radix processing standards were simply not good enough for
Javascript :-(
Depending on that the most effective workaround can be suggested.

I've gone with the Timeout strategy and it doesn't seem to barf at
zero-milliseconds. Now I have to disable a few buttons/inputs until the
whole result-set is retrieved. The potential great news here is that my
HTML/JS hot-abort key is now back on the agenda! sendUrgentData() here O
come :)

I can include the Applet code if anyone is interested and it's not all that
long. I pop-up a dialog box for username/password and pass server
authentication and, from that point on, the channel is at the disposal of my
Javascript code.

Cheers Richard Maher
 
R

Richard Maher

Hi Stephane ca va?,
And that is not our problem since we can['t] do anything about server's job
(in JavaScript client side)

The "Javascript client side" can help by unburdening the server side with
some value added processing and by helping to balance the load across CPUs
i.e. Parallelism.
rien compris ...

I appologize. As an Australian my mastery on the English Language may not
make for easy reading and, from time to time, I also like to try to be
"clever". I will in future attempt to write more clearly.

In this case my accusation was "Most people here agree with the Thin-Client
strategy and expect the server to do absolutely everything for their
Dumb-Terminals" :-(
The alone action is :
chan.sendMessage(msgGetInfo.concat(outPad,msgEntry,maxRows));
that's to say to call an applet
(applet I don't know what it make)

How do we know this applet has received an answer ?
How do we explain to JS to wait this(theses) answer(s) ?

I have included the Applet code below FYI. Basically, I prompt the user for
a Job Entry Number (or zero) and then I go look up all the matching printer
and batch jobs in the server's queues that the user has privilege to see. I
then retrieve one row per entry and insert it into the Select List until I
get an EndOfFile record. No "submitting" of forms, just feature-rich,
on-demand, result-set processing - Verstehen sie, oder :)
selectRef.options = new Option( blah );
if(i<5) selectRef.size = (+i+1);


I think that's what I'm doing, although I re-SIZE first, before appending,
and this is leaving the select-list black until it is full, so I will swap
the order around and see what happens.
// to show the option just completed :
selectRef.options.selectedIndex = i;

Does this vary functionally from selectRef.options[n].selected=true; ?

Either way I want the "heading" row selected (at least by default). I just w
ant to see that scroll bar diminish and my counter click over.
(no need ';' in end of lines : here we are in html code)

That is a shame.
Aren't we in 2007 ?

Yes we are, but once again my lament is that we don't seem to have
progressed too far. I accuse web-browsers of being glorified (albeit
colorful) IBM 3270s :-(
Both things you do are completely different :-(

At least compare similar features (empty the list) :

I don't understand. Yes, they are completely different; one populates the
list and the other depopulates it. The specific difference that I'm
interested in is in that the depopulation is echoed on the screen
*immediately* and the other requires me to surrender the event thread via
setTimer() et al. Are you saying this is not the case? Anyway, I've gone for
the setTimer strategy and it seems to do what I'm after, thanks. (I had
hoped there was a .close() or .flush() that could've helped)
for (;;) // <----- yes? for what and where ?

if (recType != jobInfo)
break;

Loop till EOF or error. Yes, it should be done in the for loop control. As I
said, "A work in progress".

Thanks again.

Cheers Richard Maher

Below is the Applet: -
{
"Tier3" is a registered trademark of Tier3 Software Ltd
"CornuCopiae" is a trademark of Richard Maher
}

import java.applet.Applet;
import java.awt.*;
import java.net.*;
import java.util.Date;
import java.io.IOException;

public class CornuCopiae extends Applet
{
private String username = "";
private String password = "";
private boolean pass = false;
private Date cxnDate;
private long cxnTime = 0;
public Tier3Socket pipe;
public String stringOut = "";
public int bytesIn;

public void init()
{
if (!authorize())
{
try
{
getAppletContext().showDocument
(new URL (getCodeBase()+"accessdenied.html"),"_top");
}
catch (Exception e) {e.printStackTrace(); }
}
else
{
try
{
getAppletContext().showDocument
(new URL
(getDocumentBase(),"queue_lookup.html"),"queue_lookup");
}
catch (Exception e) {e.printStackTrace(); }
}
}

public boolean authorize()
{
int port = Integer.parseInt(getParameter("PORT"));
int maxBuf = Integer.parseInt(getParameter("MAXBUF"));
String appl = getParameter("APPLICATION");
String hostCharSet = getParameter("HOSTCHARSET");

pipe = new Tier3Socket(getCodeBase().getHost(),
port,
maxBuf,
hostCharSet);
try {pipe.open();} catch (Exception e) {return false;}

cxnDate = new Date();
cxnTime = cxnDate.getTime();

Object parentFrame = getParent();
while ((parentFrame != null) &&
!(parentFrame instanceof Frame))
{
parentFrame = ((Component)parentFrame).getParent();
}

Frame creds = (Frame)parentFrame;

Tier3Logon logon = new Tier3Logon(creds);

requestFocus();

if (logon.logonAborted)
{
System.out.println("Logon Aborted");
}
else
{
username = logon.inUser.getText();
password = logon.inPass.getText();

pass = true;
try {pipe.handShake(username, password);}
catch (Exception e)
{
pass = false;
e.printStackTrace();
System.out.println("Logon Failed");
}
}

if (pass && logon.cb.getState())
{
Tier3Welcome welcome = new Tier3Welcome(creds, appl,
pipe.t3IdBuf);
requestFocus();
welcome.dispose();
}

logon.dispose();

password = "";
return pass;
}

public void sendMessage (String message)
{
try
{pipe.sendMessage(message);}
catch (IOException e)
{return;}
}

public void sendUrgentData (int oob)
{
try
{pipe.sendUrgentData(oob);}
catch (IOException e)
{return;}
}

public int readMessage () throws IOException
{
try
{bytesIn = pipe.readMessage();}
catch (IOException e)
{return 0;}

return bytesIn;
}
public int readMessage (int bytes) throws IOException
{
try
{bytesIn = pipe.readMessage(bytes);}
catch (IOException e)
{return 0;}

return bytesIn;
}

public String getString (int offset, int length)
{
try
{stringOut = pipe.getString(offset, length);}
catch (ArrayIndexOutOfBoundsException e)
{return null;}

return stringOut;
}

public long getConnectTime ()
{
return cxnTime;
}

public String getUsername ()
{
return username;
}

public void destroy()
{
try
{pipe.close();}
catch (IOException e)
{e.printStackTrace();}

super.destroy();
}

}

ASM said:
Richard Maher a écrit :
Hi Stephane,

Salut Richard,

(... about tables ...)
Not if the data isn't coming back in 1 to 2 seconds.

Of course !
And that is not our problem since we can do anything about server's job
(in JavaScript client side)
Is the anorexic-client strategy the prevailing mind-set everywhere in the
HTML and Javascript world?

rien compris ...
To turn off bloody batch-updating! When I change the screen I want the
screen to change. Am I not saying this right?

You only try to change content of a select (if I well saw)

The alone action is :
chan.sendMessage(msgGetInfo.concat(outPad,msgEntry,maxRows));
that's to say to call an applet
(applet I don't know what it make)

How do we know this applet has received an answer ?
How do we explain to JS to wait this(theses) answer(s) ?

I think it would be better to call back 'CornuCopiae.html' in its frame
and it would be this frame which on loaded will fix the select

(no need ';' in end of lines : here we are in html code)

<html>

<frameset rows="5%,*">

<frame
src="cornucopiae.html"

onload = parent.queue_lookup.job_lookup();"

name="cornucopiae"
blah
/>

<frame
src=""
name="queue_lookup"
blah
/>

</frameset>

If you see the html below where I say: - "document.getjobs.rec_count.value
= rc;" I want the record counter to click-over on the screen (*as the rows
are being retrieved*) Yes, this is live-TV not a delayed telecast :)


selectRef.options = new Option( blah );
if(i<5) selectRef.size = (+i+1);

// to show the option just completed :
selectRef.options.selectedIndex = i;

the thread long enough to repaint my 3270.

Aren't we in 2007 ?
(But it looks like the quasi-event inducing timer is the only way to
go?)

You'l only need a timer routine if you want to see progress in the
select, else this select is completed in once time.
But I'd still like to know why: -

while (selectRef.options.length > 0)
{
selectRef.remove(selectRef.options[0]);
}
_gets reflected on the screen immediately but: -

selectRef.options[selectRef.options.length] = new Option (jobMsg);

_does not?

Both things you do are completely different :-(

At least compare similar features (empty the list) :

while(selectRef.options.length>0)
selectRef.remove(selectRef.options[0]);
and
selectRef.options.length = 0;
IE6 on Windows2000.

I can't test with that.
queue_lookup.html (contains select list - job_list)
===================================================

as I'vn't the applet ...
and as it is a little long to follow what is it supposed to do
(going up and/or down to search where is defined this or that)

For your main question :
you empty the select by DOM
and try to fill it up via old JS

and we don't know how you get datas (what to put in options)

function process_jobs()
{
var ... blah
var selectRef = document.getjobs.job_list;

for (;;) // <----- yes? for what and where ?
{
 
V

VK

It is not clear from your description how do you handle the server
Although TCP/IP is stream oriented, in this (and many other examples) I deal
in records,
<snip>

Actually TCP/IP is "packet oriented", streams are coming into play
only on higher level protocols using TCP/IP as transport. But it is
irrelevant to your current problem - if it still persists of course.
For this problem it is absolutely irrelevant of how do you retrieve
your data from the server to your applet: using HTTP, FTP, your own
datagram sockets or Nth other way. On the given stage your applet is
simply a source of data. You may request data / you may cancel
request. To not be bothered anymore with non-relevant issues let's say
that your applet contains 1000 String inside of it with separate
records and two public methods getData() and abortRequest()
So the question is:
By invoking getData() you want that
- the applet sends all 1000 records at once to some JavaScript
function to display them on the screen?
- or the applet calls some JavaScript function 1000 times - one time
for each record - to immediately display this record on the screen?

Presumably from your previous posts you want the 2nd option but I want
to be sure.

P.S. The core of your ongoing problems is of the same kind as doing a
long loop in main() in some applet and getting it "frozen" for the
time of the loop execution. The JavaScript/DOM combo weakness is not
that it behaves in the same way - but in that it doesn't provide
repaint() method or equivalent.
 
A

ASM

Richard Maher a écrit :
Hi Stephane ca va?,

:) Ça va bien, et toi ?
I have included the Applet code below FYI.

I'll try to read it but ... I understand anything in Java.
Basically, I prompt the user for
a Job Entry Number (or zero) and then I go look up all the matching printer
and batch jobs in the server's queues that the user has privilege to see.

I thought it would do something like that.
Does the applet sends back line after line ?

then retrieve one row per entry

How do you fix that ?
I mean how the JS knows a new entry is downloaded
and ready to be shown ?
and insert it into the Select List until I
get an EndOfFile record. No "submitting" of forms, just feature-rich,
on-demand, result-set processing - Verstehen sie, oder :)

Hein ? Quoi ? moi pas parler allemand.
I'll admit the applet will food a JS variable with all found entries.
Is that possible ?
Is it possible the applet fires a JS function ?

http://stephane.moriaux.perso.wanadoo.fr/truc/batch
(a textarea simulate result of applet)
selectRef.options = new Option( blah );
if(i<5) selectRef.size = (+i+1);


I think that's what I'm doing, although I re-SIZE first, before appending,


there that does what you say :
appends a new option, then resize if necessary.
(it is in old JS)
and this is leaving the select-list black until it is full, so I will swap
the order around and see what happens.

To avoid to wait with a black or empty list
perhaps could you use a timer as that in example above

// to show the option just completed :
selectRef.options.selectedIndex = i;

Does this vary functionally from selectRef.options[n].selected=true; ?

That could
Either way I want the "heading" row selected (at least by default).

No this example was for the "I see the list growing"
On last entry you can come back to 1st option, no ?
I just w
ant to see that scroll bar diminish and my counter click over.

I don't know what is this scroll bar ...
so to see it diminishing ... it's not won in advance ...
The counter is not a problem.
Yes we are,

I tried to be so explicit you are, translation :
"don't know what is 3270"
I accuse web-browsers of being glorified (albeit
colorful) IBM 3270s :-(

Not more lighted (and no importance)
I don't understand. Yes, they are completely different; one populates the
list and the other depopulates it.

Hu ? both did empty the list.
I understood that you say 1st was immediate and not the 2nd.
The specific difference that I'm
interested in is in that the depopulation is echoed on the screen
*immediately*

complete list --> empty list in one time, right?
and the other requires me to surrender the event thread via
setTimer() et al. Are you saying this is not the case?

document.myForm.mySelect.length = 0;
document.myForm.mySelect.size = 1;
empty the list (and its display) suddenly, yes.
 
R

Richard Maher

Hi Stephane,

Thanks for the reply and sorry for the delay.
:) Ça va bien, et toi ?

Non ci male :)

(Sorry, my French is just about non-existant, my Italian is from
high-school, and my Deutsche was getting past the restaurant stage when we
lived in Munich, but now I'm just left grappling with English)
Does the applet sends back line after line ?

Yes. You ask for a line, put it in the select list, ask for another line,
and so on until EOF.
How do you fix that ?
I mean how the JS knows a new entry is downloaded
and ready to be shown ?

Application-specific protocol. In this case the first two bytes of every
message contain a message-id which implies the format and size of the
remaining bytes to be read. In this case a "10" request can receive numerous
"11" response messages; it's up to the client to make sure he reads them
all. Very simple.
Hein ? Quoi ? moi pas parler allemand.

Warum nicht? :)

Thank-you for taking the time to do that!

That *is* what I'm trying to do.
appending,

there that does what you say :
appends a new option, then resize if necessary.

That made all the difference; thanks.
I don't know what is this scroll bar ...
so to see it diminishing ... it's not won in advance ...
The counter is not a problem.

With IE6 W2K, when the Length of a Select List exceeds its Size then a
scroll bar appears on the right hand side and it diminishes as the disparity
grows when new Options are inserted. This is true of all browsers no?
I tried to be so explicit you are, translation :
"don't know what is 3270"

An IBM 3270 was/is a dumb(ish) green-screen/terminal/CRT that would take
Block-Mode input and "submit" a screen full for processing in a similar
fashion to what most browsers do today. I sought to draw an analogy between
the seemingly modern day User Interface and that of the dinosaurs. Alors,
it is not important.
complete list --> empty list in one time, right?

I was looping using the .remove(.options[0]) method, and as the options were
removed they disappeared *immediately* and what's more, if the selected
option was currently number 1456 then I *saw* the list scroll back to 0
before the remove started.
document.myForm.mySelect.length = 0;
document.myForm.mySelect.size = 1;
empty the list (and its display) suddenly, yes.

Is there a potention for a memory leek here? When do all of the previous
"new option()"s get garbage collected? Is it true that I *never* have to
"remove()" them?

Anyway, it looks much better now. The list doesn't reSIZE to 1 immediately
(until I exit the function) but I'm happy.

Cheers Richard Maher

ASM said:
Richard Maher a écrit :
Hi Stephane ca va?,

:) Ça va bien, et toi ?
I have included the Applet code below FYI.

I'll try to read it but ... I understand anything in Java.
Basically, I prompt the user for
a Job Entry Number (or zero) and then I go look up all the matching printer
and batch jobs in the server's queues that the user has privilege to
see.

I thought it would do something like that.
Does the applet sends back line after line ?

then retrieve one row per entry

How do you fix that ?
I mean how the JS knows a new entry is downloaded
and ready to be shown ?
and insert it into the Select List until I
get an EndOfFile record. No "submitting" of forms, just feature-rich,
on-demand, result-set processing - Verstehen sie, oder :)

Hein ? Quoi ? moi pas parler allemand.
I'll admit the applet will food a JS variable with all found entries.
Is that possible ?
Is it possible the applet fires a JS function ?

http://stephane.moriaux.perso.wanadoo.fr/truc/batch
(a textarea simulate result of applet)
selectRef.options = new Option( blah );
if(i<5) selectRef.size = (+i+1);


I think that's what I'm doing, although I re-SIZE first, before
appending,

there that does what you say :
appends a new option, then resize if necessary.
(it is in old JS)
and this is leaving the select-list black until it is full, so I will swap
the order around and see what happens.

To avoid to wait with a black or empty list
perhaps could you use a timer as that in example above

// to show the option just completed :
selectRef.options.selectedIndex = i;

Does this vary functionally from selectRef.options[n].selected=true; ?

That could
Either way I want the "heading" row selected (at least by default).

No this example was for the "I see the list growing"
On last entry you can come back to 1st option, no ?
I just w
ant to see that scroll bar diminish and my counter click over.

I don't know what is this scroll bar ...
so to see it diminishing ... it's not won in advance ...
The counter is not a problem.
Yes we are,

I tried to be so explicit you are, translation :
"don't know what is 3270"
I accuse web-browsers of being glorified (albeit
colorful) IBM 3270s :-(

Not more lighted (and no importance)
I don't understand. Yes, they are completely different; one populates the
list and the other depopulates it.

Hu ? both did empty the list.
I understood that you say 1st was immediate and not the 2nd.
The specific difference that I'm
interested in is in that the depopulation is echoed on the screen
*immediately*

complete list --> empty list in one time, right?
and the other requires me to surrender the event thread via
setTimer() et al. Are you saying this is not the case?

document.myForm.mySelect.length = 0;
document.myForm.mySelect.size = 1;
empty the list (and its display) suddenly, yes.
 

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,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top