473,396 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Urgent: Calling a method of a java object (getting a boolean parameter) from java script

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>
Jul 20 '05 #1
2 6874
Hi,

Eyal wrote:
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>


Two thoughts:

1) What does the Java console say? In Internet Explorer, choose the menu
Tools / Sun Java console or the equivalent.

2) If your project is urgent, and you don't have time to look for
solutions, can you use the applet as an interface to the Java object, like

document.myApplet.method3( ... );

with:

public void method3(boolean param)
{
IMyInteface2 result = new MyJavaObject2();
return result.method3();
}

I would rather try to find why the first solution doesn't work, but this
one is worth a test.

HTH,

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #2
Hi,

Thanks for your try, but I think I found the reason...apparently it's
a bug of the java plugin 1.3.1 for IE (bug reference Id: 4528785)

Regards,

Eyal
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gilles A. | last post by:
Hi all, Does anyone know how to get the class.method name of the calling method? Example public class A { public void m() { new B().method();
3
by: Alexander Fillips | last post by:
Hi, my short question: is there a python object which can interpret java-script? the whole story ;-) I wrote some streaming-scripts for the xbox mediaplayer which supports python. for a...
5
by: Matt | last post by:
I have a simple JS function that I want to return a true or false value based on the parameter passed in. At this point of time I receive the error "'True' is undefined". Here is my code below. ...
0
by: John Puopolo | last post by:
All, Let's s suppose I have C# program that hosts the VB.NET scripting engine (via VSA run-time). The host loads a VB.NET script from the disk. The script contains a method that takes an "int"...
5
by: Ram | last post by:
Hi Friends I want to develope a custom control in .net which can be used with any project. I am writing a function in that class which I want to take any object as parameter. For that I have...
10
by: Zoe Hart | last post by:
I have a wsdl file that I received from a third party and I'm using wsdl.exe (.NET 2.0) to import it and generate a proxy class. I've actually got a proxy class that works, but I'm trying to...
2
by: Charlie | last post by:
Hi: I'm using the ObjectDataSource control to databind a Repeater. The method on business object that ObjectDataSource control point to takes as a parameter an instance of the...
0
by: kokababu | last post by:
Hi, I have to add xml schema attributes into the java object. Such as, my java object is User. This User object will be represented as XML using JAXB. I generated XML from User object...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.