Path: csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: "Richard Maher" Newsgroups: comp.lang.java.programmer,comp.lang.javascript Subject: Java7 Applet Status and Event Handlers Date: Thu, 26 Apr 2012 20:42:52 +0800 Organization: HTTP *is* The Box - Let's think outside Lines: 212 Message-ID: NNTP-Posting-Host: jOhPn0KFjrxwuMc9OPMmCw.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-RFC2646: Format=Flowed; Original X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-Priority: 3 X-MSMail-Priority: Normal Xref: csiph.com comp.lang.java.programmer:13914 comp.lang.javascript:13606 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/tutorial/deployment/applet/examples/dist/applet_StatusAndCallback/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":port }, {"name":"MAXBUF", "value":maxBuf }, {"name":"HOSTCHARSET", "value":hostCharSet}, {"name":"SSLREQD", "value":sslReqd }]; var startParam = 0; var objectTag = "'; for (i=startParam; i'; } objectTag = objectTag + ""; 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