R
Richard Maher
Hi,
I found the following pages and find them very interesting and useful: -
http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/applet/appletStatus.html
http://docs.oracle.com/javase/tutorial/deployment/applet/appletStatus.html
a good example of use: -
http://docs.oracle.com/javase/tutor...dCallback/AppletPageUpdatedDuringLoading.html
The only thing is, I'd really much rather stick to my old and very simple
strategy of "app=document.getElementById(appletId); app.someMethod();" and
block synchronously until the applet is loaded. The problem is that although
that strategy works like a charm with FireFox, Opera, and Safari, it falls
over on slow machines on the JVM initialization when using Chrome or IE :-(
So I'm thinking new Applet event handling in Java 7 would lead one to
believe this is the way to go but, alternatively, if someone can show me a
simple way to reintroduce the blocking behaviour with IE and Chrome I'd much
appreciate it! Some want/require a "lazy load" but I do not!
Cheers Richard Maher
PS. Below is the existing code that I guess I'm going to have to introduce
the JAVA_STATUS_EVENTS parameter to: -
/**
* Copyright (c) Richard Maher. All rights reserved.
*
*/
function Tier3Client(application,
codeBase,
port,
maxBuf,
hostCharSet,
sslReqd)
{
this.facPrefix = "T3$";
this.application = application;
this.codeBase = codeBase;
this.port = port;
this.maxBuf = maxBuf;
this.hostCharSet = hostCharSet;
this.sslReqd = sslReqd;
this.msgPend = new Array();
var appletId = "Tier3__" + application + "_Applet";
try {
var idTaken = document.getElementById(appletId);
}
catch (err) {};
if (idTaken != null) {
throw new Error("Tier3 Client already registered for " +
this.application);
return;
}
var archiveName = "tier3Client.jar";
var className = "tier3Client/Tier3Application";
var appletParams = [{"name":"archive", "value":archiveName},
{"name":"codebase", "value":codeBase },
{"name":"code", "value":className },
{"name":"mayscript", "value":"true" },
{"name":"scriptable", "value":"true" },
{"name":"APPLICATION", "value":application},
{"name":"PORT", "value"
ort },
{"name":"MAXBUF", "value":maxBuf },
{"name":"HOSTCHARSET", "value":hostCharSet},
{"name":"SSLREQD", "value":sslReqd }];
var startParam = 0;
var objectTag = "<object classid=";
if (/Internet Explorer/.test(navigator.appName)) {
objectTag = objectTag +
'"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" ';
} else {
objectTag = objectTag +
'"java:' + className + '.class" type="application/x-java-applet
" ' +
'archive="' + codeBase + archiveName + '"';
startParam = 1;
}
objectTag = objectTag + ' width= "0" height= "0" id="' + appletId +
'">';
for (i=startParam; i<appletParams.length; i++){
objectTag = objectTag + '<param name ="' + appletParams.name +
'" ' +
'value ="' + appletParams.value +
'">';
}
objectTag = objectTag + "</object>";
var appletDiv = document.createElement("div");
appletDiv.innerHTML = objectTag;
try {
document.body.appendChild(appletDiv);
this.chan = document.getElementById(appletId);
}
catch(err) {
alert("Tier3 unable to load applet for " + this.application +
": -\n" + err.description);
this.chan = null;
};
if (this.chan == null) {
throw new Error("Tier3 was unable to initialize the applet for " +
this.application);
return;
} else {
if (!this.chan.isAuthorized()) {
throw new Error("Tier3 User authentication unsuccessful for " +
this.application);
return;
}
}
Tier3Client.applications[this.application] = this;
return this;
}
Tier3Client.MAJVERS = 1;
Tier3Client.MINVERS = 0;
Tier3Client.launder =
function(jsobject) {
return jsobject;
};
Tier3Client.prototype = {
send:
function(msgBody, callback)
{
if (arguments.length < 2) {
throw new Error("Insufficient arguments for send(msgBody,
callback)");
}
var chan = this.chan;
var callbackArgs = new Array();
var responseCnt = 0;
var i = 0;
var msgCandidate =
{
msgSlotId : -1,
msgSeqNum : -1,
chan : chan,
callback : callback,
callbackArgs : callbackArgs,
dispatcher :
function(responseMsg,
msgSlotId,
msgSeqNum)
{
this.responseCnt++;
this.msgSlotId = msgSlotId;
this.msgSeqNum = msgSeqNum;
callbackArgs[0] = responseMsg;
try {
callback.apply(this, callbackArgs);
}
catch (err) {
throw new Error("Error calling callback
routine: -\n" + err.description);
}
},
getMsgSeqNum :
function() {
return this.msgSeqNum;
},
getResponseCnt:
function() {
return this.responseCnt;
},
complete :
function() {
return chan.complete(this.msgId);
}
};
if (typeof callback != "function") {
throw new Error("The 'callback' parameter is not a
function");
}
for (i=2; i<arguments.length; i++) {
callbackArgs[i - 1] = arguments;
}
return chan.send(msgCandidate, msgBody);
}
};
Tier3Client.applications = {};
I found the following pages and find them very interesting and useful: -
http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/applet/appletStatus.html
http://docs.oracle.com/javase/tutorial/deployment/applet/appletStatus.html
a good example of use: -
http://docs.oracle.com/javase/tutor...dCallback/AppletPageUpdatedDuringLoading.html
The only thing is, I'd really much rather stick to my old and very simple
strategy of "app=document.getElementById(appletId); app.someMethod();" and
block synchronously until the applet is loaded. The problem is that although
that strategy works like a charm with FireFox, Opera, and Safari, it falls
over on slow machines on the JVM initialization when using Chrome or IE :-(
So I'm thinking new Applet event handling in Java 7 would lead one to
believe this is the way to go but, alternatively, if someone can show me a
simple way to reintroduce the blocking behaviour with IE and Chrome I'd much
appreciate it! Some want/require a "lazy load" but I do not!
Cheers Richard Maher
PS. Below is the existing code that I guess I'm going to have to introduce
the JAVA_STATUS_EVENTS parameter to: -
/**
* Copyright (c) Richard Maher. All rights reserved.
*
*/
function Tier3Client(application,
codeBase,
port,
maxBuf,
hostCharSet,
sslReqd)
{
this.facPrefix = "T3$";
this.application = application;
this.codeBase = codeBase;
this.port = port;
this.maxBuf = maxBuf;
this.hostCharSet = hostCharSet;
this.sslReqd = sslReqd;
this.msgPend = new Array();
var appletId = "Tier3__" + application + "_Applet";
try {
var idTaken = document.getElementById(appletId);
}
catch (err) {};
if (idTaken != null) {
throw new Error("Tier3 Client already registered for " +
this.application);
return;
}
var archiveName = "tier3Client.jar";
var className = "tier3Client/Tier3Application";
var appletParams = [{"name":"archive", "value":archiveName},
{"name":"codebase", "value":codeBase },
{"name":"code", "value":className },
{"name":"mayscript", "value":"true" },
{"name":"scriptable", "value":"true" },
{"name":"APPLICATION", "value":application},
{"name":"PORT", "value"
{"name":"MAXBUF", "value":maxBuf },
{"name":"HOSTCHARSET", "value":hostCharSet},
{"name":"SSLREQD", "value":sslReqd }];
var startParam = 0;
var objectTag = "<object classid=";
if (/Internet Explorer/.test(navigator.appName)) {
objectTag = objectTag +
'"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" ';
} else {
objectTag = objectTag +
'"java:' + className + '.class" type="application/x-java-applet
" ' +
'archive="' + codeBase + archiveName + '"';
startParam = 1;
}
objectTag = objectTag + ' width= "0" height= "0" id="' + appletId +
'">';
for (i=startParam; i<appletParams.length; i++){
objectTag = objectTag + '<param name ="' + appletParams.name +
'" ' +
'value ="' + appletParams.value +
'">';
}
objectTag = objectTag + "</object>";
var appletDiv = document.createElement("div");
appletDiv.innerHTML = objectTag;
try {
document.body.appendChild(appletDiv);
this.chan = document.getElementById(appletId);
}
catch(err) {
alert("Tier3 unable to load applet for " + this.application +
": -\n" + err.description);
this.chan = null;
};
if (this.chan == null) {
throw new Error("Tier3 was unable to initialize the applet for " +
this.application);
return;
} else {
if (!this.chan.isAuthorized()) {
throw new Error("Tier3 User authentication unsuccessful for " +
this.application);
return;
}
}
Tier3Client.applications[this.application] = this;
return this;
}
Tier3Client.MAJVERS = 1;
Tier3Client.MINVERS = 0;
Tier3Client.launder =
function(jsobject) {
return jsobject;
};
Tier3Client.prototype = {
send:
function(msgBody, callback)
{
if (arguments.length < 2) {
throw new Error("Insufficient arguments for send(msgBody,
callback)");
}
var chan = this.chan;
var callbackArgs = new Array();
var responseCnt = 0;
var i = 0;
var msgCandidate =
{
msgSlotId : -1,
msgSeqNum : -1,
chan : chan,
callback : callback,
callbackArgs : callbackArgs,
dispatcher :
function(responseMsg,
msgSlotId,
msgSeqNum)
{
this.responseCnt++;
this.msgSlotId = msgSlotId;
this.msgSeqNum = msgSeqNum;
callbackArgs[0] = responseMsg;
try {
callback.apply(this, callbackArgs);
}
catch (err) {
throw new Error("Error calling callback
routine: -\n" + err.description);
}
},
getMsgSeqNum :
function() {
return this.msgSeqNum;
},
getResponseCnt:
function() {
return this.responseCnt;
},
complete :
function() {
return chan.complete(this.msgId);
}
};
if (typeof callback != "function") {
throw new Error("The 'callback' parameter is not a
function");
}
for (i=2; i<arguments.length; i++) {
callbackArgs[i - 1] = arguments;
}
return chan.send(msgCandidate, msgBody);
}
};
Tier3Client.applications = {};