473,714 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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)param eter. 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.inte rfaces;

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.myOb ject2;

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.Test Applet;

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=JavaSc ript>
function Execute()
{
var myApplet = document.myAppl et;
myApplet.method 3(false);//this one is fine (getting boolean)

var myJavaObj2 = myApplet.newJav aObject2();
myJavaObj2.meth od1("Test"); //this one is fine (getting String)
myJavaObj2.meth od2(1); //this one is fine (getting int)
myJavaObj2.meth od3(false); //this one fails (getting boolean)
myJavaObj2.meth od3("false"); //this one fails (getting boolean)
myJavaObj2.meth od3(0); //this one fails (getting boolean)
myJavaObj2.meth od3(""); //this one fails (getting boolean)
}
</script>

-------------------------
Html Code (plug in tag):
-------------------------

<OBJECT ID="SmartFileCa talog"
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#Versio n=1,3,1,8">

<PARAM NAME = CODE VALUE = "name.space.Tes tApplet.class" >
<PARAM NAME = CODEBASE VALUE = ".">
<PARAM NAME = NAME VALUE = "MyApplet" >
<PARAM NAME = ARCHIVE VALUE = "MyTestApplet.j ar" >
<PARAM NAME = "type"
VALUE="applicat ion/x-java-applet;jpi-version=1.3.1_0 8">
<PARAM NAME = "scriptable " VALUE="true">

</OBJECT>
Jul 20 '05 #1
2 6923
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)param eter. 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.inte rfaces;

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.myOb ject2;

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.Test Applet;

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=JavaSc ript>
function Execute()
{
var myApplet = document.myAppl et;
myApplet.method 3(false);//this one is fine (getting boolean)

var myJavaObj2 = myApplet.newJav aObject2();
myJavaObj2.meth od1("Test"); //this one is fine (getting String)
myJavaObj2.meth od2(1); //this one is fine (getting int)
myJavaObj2.meth od3(false); //this one fails (getting boolean)
myJavaObj2.meth od3("false"); //this one fails (getting boolean)
myJavaObj2.meth od3(0); //this one fails (getting boolean)
myJavaObj2.meth od3(""); //this one fails (getting boolean)
}
</script>

-------------------------
Html Code (plug in tag):
-------------------------

<OBJECT ID="SmartFileCa talog"
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#Versio n=1,3,1,8">

<PARAM NAME = CODE VALUE = "name.space.Tes tApplet.class" >
<PARAM NAME = CODEBASE VALUE = ".">
<PARAM NAME = NAME VALUE = "MyApplet" >
<PARAM NAME = ARCHIVE VALUE = "MyTestApplet.j ar" >
<PARAM NAME = "type"
VALUE="applicat ion/x-java-applet;jpi-version=1.3.1_0 8">
<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.myAppl et.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...appare ntly 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
8006
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
2369
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 new script i tried to filter the stream-url from an
5
5978
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. JS Function - function ShowSpecifiedPeriod(pShowPerio­d){
0
1083
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" parameter. How does the C# host program call the method in the script with the int parameter? What interfaces should I be looking at? Thanks, John
5
7458
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 used Object class as parameter. Now it can take any object as its parameter. But the problem is that I want to access the values of the private or public member variables of the passed object, for which I may have to typecast the Object class...
10
2337
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 understand why wsdl.exe did what it did and whether or not the complexity it's added to the interface is necessary or avoidable. The wsdl file specifies a Boolean parameter pAggregatePurses for one of the web service methods. In the proxy class...
2
1721
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 System.Data.CommandType enumeration. When setting up declaritively in HTML, how do I complete the following parameter assignment... <asp:Parameter Name="commandType" Type="Object" DefaultValue="????" />
0
1811
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 successfully using JAXB. But I want to add xml schema attributes such as <User xmlns="http://testws/rest/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
0
8801
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9174
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9074
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9015
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5947
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4464
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3158
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2520
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2110
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.