E
Eyal
Hey,
I would appriciate if anyone can help on this one:
I have a java object/inteface having a method with a boolean
parameter. As I'm trying to call this method from a javascript it
fails on a type mismatch.
It is positively because of the boolean(java primitive)parameter. It
goes fine if I change this parameter to int or String.
This inteface has a lot more methods which works fine, it is just the
one with the boolean parameter who makes problems.
Another thing I have noticed is that if I put the same method in an
applet and call it from the javascript it goes fine.
Please note that I'm using IE with plugin of 1.3.1_08.
my code lokks as following:
-------------------------
Java Code:
-------------------------
package name.space.interfaces;
interface IMyInterface1
{
public IInteface2 newJavaObject2();
public void method3(boolean param1);
}
interface IMyInterface2
{
public void method1(String param);
public void method2(int param);
public void method3(boolean param);
}
--------------------------------------------
package name.space.myObject2;
public class MyJavaObject2 implements IMyInterface2
{
public void method1(String param)
{
some code....
}
public void method2(int param);
{
some code....
}
public void method3(boolean param);
{
some code....
}
}
----------------------------------------------------
package name.space.TestApplet;
public class MyApplet extends Applet implements IMyInterface1,
{
public void method3(boolean param)
{
some code....
}
public IMyInteface2 newJavaObject2()
{
IMyInteface2 result = new MyJavaObject2();
return result;
}
}
-------------------------
javascript Code:
-------------------------
<script language=JavaScript>
function Execute()
{
var myApplet = document.myApplet;
myApplet.method3(false);//this one is fine (getting boolean)
var myJavaObj2 = myApplet.newJavaObject2();
myJavaObj2.method1("Test"); //this one is fine (getting String)
myJavaObj2.method2(1); //this one is fine (getting int)
myJavaObj2.method3(false); //this one fails (getting boolean)
myJavaObj2.method3("false"); //this one fails (getting boolean)
myJavaObj2.method3(0); //this one fails (getting boolean)
myJavaObj2.method3(""); //this one fails (getting boolean)
}
</script>
-------------------------
Html Code (plug in tag):
-------------------------
<OBJECT ID="SmartFileCatalog"
classid="clsid:CAFEEFAC-0013-0001-0008-ABCDEFFEDCBA" WIDTH = 100
HEIGHT = 100 NAME = "MyApplet"
codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_3_1_08-windows-i586.cab#Version=1,3,1,8">
<PARAM NAME = CODE VALUE = "name.space.TestApplet.class" >
<PARAM NAME = CODEBASE VALUE = ".">
<PARAM NAME = NAME VALUE = "MyApplet" >
<PARAM NAME = ARCHIVE VALUE = "MyTestApplet.jar" >
<PARAM NAME = "type"
VALUE="application/x-java-applet;jpi-version=1.3.1_08">
<PARAM NAME = "scriptable" VALUE="true">
</OBJECT>
I would appriciate if anyone can help on this one:
I have a java object/inteface having a method with a boolean
parameter. As I'm trying to call this method from a javascript it
fails on a type mismatch.
It is positively because of the boolean(java primitive)parameter. It
goes fine if I change this parameter to int or String.
This inteface has a lot more methods which works fine, it is just the
one with the boolean parameter who makes problems.
Another thing I have noticed is that if I put the same method in an
applet and call it from the javascript it goes fine.
Please note that I'm using IE with plugin of 1.3.1_08.
my code lokks as following:
-------------------------
Java Code:
-------------------------
package name.space.interfaces;
interface IMyInterface1
{
public IInteface2 newJavaObject2();
public void method3(boolean param1);
}
interface IMyInterface2
{
public void method1(String param);
public void method2(int param);
public void method3(boolean param);
}
--------------------------------------------
package name.space.myObject2;
public class MyJavaObject2 implements IMyInterface2
{
public void method1(String param)
{
some code....
}
public void method2(int param);
{
some code....
}
public void method3(boolean param);
{
some code....
}
}
----------------------------------------------------
package name.space.TestApplet;
public class MyApplet extends Applet implements IMyInterface1,
{
public void method3(boolean param)
{
some code....
}
public IMyInteface2 newJavaObject2()
{
IMyInteface2 result = new MyJavaObject2();
return result;
}
}
-------------------------
javascript Code:
-------------------------
<script language=JavaScript>
function Execute()
{
var myApplet = document.myApplet;
myApplet.method3(false);//this one is fine (getting boolean)
var myJavaObj2 = myApplet.newJavaObject2();
myJavaObj2.method1("Test"); //this one is fine (getting String)
myJavaObj2.method2(1); //this one is fine (getting int)
myJavaObj2.method3(false); //this one fails (getting boolean)
myJavaObj2.method3("false"); //this one fails (getting boolean)
myJavaObj2.method3(0); //this one fails (getting boolean)
myJavaObj2.method3(""); //this one fails (getting boolean)
}
</script>
-------------------------
Html Code (plug in tag):
-------------------------
<OBJECT ID="SmartFileCatalog"
classid="clsid:CAFEEFAC-0013-0001-0008-ABCDEFFEDCBA" WIDTH = 100
HEIGHT = 100 NAME = "MyApplet"
codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_3_1_08-windows-i586.cab#Version=1,3,1,8">
<PARAM NAME = CODE VALUE = "name.space.TestApplet.class" >
<PARAM NAME = CODEBASE VALUE = ".">
<PARAM NAME = NAME VALUE = "MyApplet" >
<PARAM NAME = ARCHIVE VALUE = "MyTestApplet.jar" >
<PARAM NAME = "type"
VALUE="application/x-java-applet;jpi-version=1.3.1_08">
<PARAM NAME = "scriptable" VALUE="true">
</OBJECT>