Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2006

Tip: Looking for answers? Try searching our database.

IE with OBJECT-tag for applet issue

Thread view: 
andrewfsears@gmail.com - 07 Dec 2006 01:52 GMT
Okay, I've got one that i'm not so sure about, and i don't know if this
belongs here...

I have an applet that is an extension of the JApplet class.
To avoid cross-browser issues with loading it, I use a javascript to
create the applet tag in the web page: <embed> for Netscape/Firefox,
<object> for IE, <applet> for "else" (for good measure, these tags also
have the safeguard to ensure that JRE 1.4+ is installed).

These will load the applet correctly, except when the JRE is installed.
After installation, in IE only, when i try to retrieve the applet
object in a Javascript code (for example: appletObject.isActive), it
does not get the applet.  Instead, when i "alert" the object by calling
    document.getElementById("theApplet");
i get the following message:

com.company.MyApplet[panel2,0,0,400x500,layout=java.awt.BorderLayout,rootPane=javax.swing.JRootPane[,0,0,400x500,layout=javax.swing.JRootPane$RootLayout,alignmentX=null,alignmentY=null,border=,flags=385,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]

The <object>-tag that is generated looks correct when I "alert" that.

Anyone have any idea why?

Also, after installing the JRE, rebooting, clearing caches, internet
pages, etc. does not make a difference.
Andrew Thompson - 07 Dec 2006 02:38 GMT
> Okay, I've got one that i'm not so sure about, and i don't know if this
> belongs here...
>
> I have an applet that is an extension of the JApplet class.
> To avoid cross-browser issues with loading it,

..try web-start - E.G. <http://www.physci.org/pc/jtest-applet.jnlp>

Andrew T.
andrewfsears@gmail.com - 08 Dec 2006 22:06 GMT
Andrew T.,
Thank you for the response, but it turned out it was something
completely different than what I initially thought.

If anyone is looking for a solution to this, here's the short of it:
DEBUG your JavaScript code.

And with Internet Explorer, this can be really tricky, especially
trying to figure out what the issue is with their messages being less
than helpful.

Here's where my issue resolved to...

My applet uses the Netscape LiveConnect to communicate between the
JavaScript and the Java.  I had a
   setupApplet(String name, int width, int height) {...}
method in my Applet code, and then in my JavaScript, i had the
following lines:
   var theApplet = document.getElementById("theAppletName");
   if (theApplet.isActive) theApplet.setupApplet("name",
theApplet.width, theApplet.height);
or something like that.

Now, before the JRE update, it would work correctly.  After the JRE
update, it worked fine in Firefox, but in IE, it did not.  Here's the
reason(s): it turns out that in IE, the "theApplet.width" was returning
a string-version of the number, and then trying to pass in a string
where an integer should be.  IE didn't like it, and thus kicked a (not
so helpful) error.  Also, because of the Applet class being returned,
"theApplet.isActive" is not going to work as well, because it's not a
proper method call.

So, the resulting line should be:
   if (theApplet.isActive()) theApplet.setupApplet("name",
parseInt(theApplet.width), parseInt(theApplet.height));

Here's my new question: why would the call work before any JRE upgrade?

Thanks, Andy


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.