Solution: Java Applet using getSelectedDocuments() using MS and Sun JVMs
Posted by Jeffery Sorensen on 5.Oct.03 at 上午 11:25 using a Web browser
Category: Applications Development
Release: All Releases
Platform: All Platforms
I discovered a solution to being able to use the Java getSelectedDocuments() function using both IE and MS and Sun JVMs. This Java method reports which documents the user has selected in the Java View applet and is useful for web applications which use the Domino Java View applet.
When using Internet Explorer, most people use the getSelectedDocumentsEx() function, since it returns a Vector object. Internet Explorer (even at version 6) has a problem processing Java Arrays of Strings. Netscape is fine with it, however.
If using the Microsoft JVM, the getSelectedDocumentsEx() works fine. However, since the court case with Sun, Microsoft are refusing to ship or redirect to Microsoft's JVM going forward. All new versions of Windows XP do not come with Java and will not download Microsoft's VM any more.
This presents a problem. The only Sun JVM I have found to work with Domino is version 1.4.0_03 (which ships with Netscape 7.02 incidentally). Even if you get this version downloaded, the getSelectedDocumentsEx() function does not work using a Sun JVM on a Windows PC. You must use the getSelectedDocument() function, but as mentioned, Internet Explorer does not understand Java String Arrays, so it's catch 22.
I have discovered a workaround that allows you to use either the Microsoft JVM or the Sun JVM on a Windows PC and have the code work on Netscape as well.
Here it is. I'm sure the Javascript code could be improved, I would welcome any suggestions:
// code start
var viewApplet = document.applets.view;
var docs = viewApplet.getSelectedDocuments();
if (navigator.appName == 'Microsoft Internet Explorer') {
var cbb = new VBArray(docs);
var docs = cbb.toArray();
}
var i;
for (i = 0; i < docs.length; i++) {
alert("i(" + i + ")=" + docs[i]);
}
// code end
Based on the number of entries this issue has created, I figured there would be interest in posting this solution. Hope you find it useful.
Cheers
源文档