Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Trying to call Java applet method via javascript from an on button click

843807Jan 16 2008 — edited Jan 16 2008
Have Error: "Error: Object doesn't support this property or method"; Object/Embed

I am admittedly new to html/javascript/applets, and I was
attempting to simply call a method(other the standard init/start/paint etc that are automatically called) in my Java applet.

I have looked as much as I could around the Net, tried to make sure I understand the documentation on this(I have listed the links below I have tried looking at/tried comprehending and implementing.

http://java.sun.com/products/plugin/1.3/docs/jsobject.html
http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/using_tags.html
http://www.rgagnon.com/javadetails/java-0170.html
http://www.realapplets.com/tutorial/index.html
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5011139


First, I must say that if I am to put my OBJECT or EMBED in the header or body of the html document, it is called nicely-as mentioned above, the init, start, paint, etc. are called automatically. However, when I place a button in a form and scripted an onclick call, (as I thought was done in a number of places) or just plain called the applet method from the body(another example I thought I saw) as an onclick, I receive the error message (in IE 7) mentioned in the subject, and I receive a similar message in Firebug, firefox 2.0.0.11/Mozilla 5.0- �appletName.method is not a function�
My JVM is
I should also note that the same error occurs whether I call a method I named on my own in the applet, or when calling an overridden method-the overridden methods only seem to work when the document loads along with the applet. When I read the last link, I kind of wondered if I was fitting into this bug, but was not sure-am not signing my applet, but my code is pretty much like this. Below, I have only posted the OBJECT code to shrink things a little bit-I am sorry to start out with such a long post!,

As you can probably see from my above writings, I am definitely new to this, and would appreciate any and all feedback! Thank you for your time!




Here is my code:

Java Applet:

import java.applet.*;
import java.awt.*;

public class Execjapp extends Applet
{
static final long serialVersionUID = 1;

// The method that will be automatically called when the applet is started
public void init()
{
// required, needs nothing.

}
public void start()
{

// required, needs nothing.
}


public void stop()
{
// not required, needs nothing, may use
}



public void paint(Graphics g)
{
// required, needs nothing.

}

public void invokeCommand()
{

System.out.println( "I finally got here!?!" );
}
}


html file:

<html>
<head>


</head>


<body>
<SCRIPT language="JavaScript">
function startviclient(){
document.location = "/folder/runApplet.htm";
// Change the url to a reference
}
function startObject() {
document.appform.execApp.start();
}

</SCRIPT>

<form name="execAppFor" >
<input type="button" name = "bttn1" value="Invoke" onclick=execApp.start() />
</form>

<object name="execApp" classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="0" height="0">
<param name="code" value="execjappVMware.Execjapp.class" />
<param name="codebase" value="./RunApp" />
<param name="MAYSCRIPT" value="true" />
<param name="scriptable" value="true" />
</object>


</body>
</html>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 13 2008
Added on Jan 16 2008
2 comments
404 views