473,653 Members | 3,000 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

LiveConnect writing to wrong field.

Hi,

I've created a Java Applet that allows the user to select a record. As the
user makes the selection, the applet uses LiveConnect (JSObject) to write
the record id to a html field (the name of which is passed in to the applet
as an arg).

This all works fine, but now I have two instances of the same applet
running on a page, both linked to different HTML fields so that making a
selection from applet 1 updates html field 1, a selection from applet 2
updates html field 2. This works for 90% of the time. However, on the odd
occasion one of the applets will write to the other applet's field (and the
other will continue to work normally). Refresh the page and everything
works fine again.

I'm not sure why this is happening and it is driving me crazy! I wondered
if anyone else has run into the same problem.

Thanks in advance for any help.

Alan.
Jul 23 '05 #1
3 1523


Alan Pocklington wrote:
I've created a Java Applet that allows the user to select a record. As the
user makes the selection, the applet uses LiveConnect (JSObject) to write
the record id to a html field (the name of which is passed in to the applet
as an arg).

This all works fine, but now I have two instances of the same applet
running on a page, both linked to different HTML fields so that making a
selection from applet 1 updates html field 1, a selection from applet 2
updates html field 2. This works for 90% of the time. However, on the odd
occasion one of the applets will write to the other applet's field (and the
other will continue to work normally). Refresh the page and everything
works fine again.

I'm not sure why this is happening and it is driving me crazy! I wondered
if anyone else has run into the same problem.


How do you identify and access the HTML "fields"? Are those form fields?
Is the problem happening with a particular browser?

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2
Hi,

A typical field would be retrieved as a JSObject using the Java method
loadJSTextField shown below, passing in for example document.forms
[0].elements['jobDescription .ID'] as the fieldName.

I then use returnedJSObjec t.setMember("va lue", "newValue") to set the new
value. Reading values is achieved via getMember("valu e");

The problem is occuring in IE6. It doesn't work full stop in Netscape 4.6
but that's another story and it's only a requirement that it works in IE.

I've just downloaded the lastest netscape.javasc ript.classes in the hope
that this fixes the problem. It's a hard thing to test as, like I said,
it work's 90% of the time, it's just on the odd occasion it writes to the
wrong field.

Any help will be greatly appreciated.
private JSObject loadJSTextField (String fieldName) {
JSObject jsElement;

try {
// Get root.
jsElement = (JSObject) JSObject.getWin dow(this);

// Check for null field name.
if (fieldName == null || fieldName.trim( ).equals(""))
return null;

jsElement = (JSObject) jsElement.eval( fieldName);

// Return reference.
return jsElement;

} catch (Exception jsExp) {
return null;
}
}

Martin Honnen <ma*******@yaho o.de> wrote in
news:40******** @olaf.komtel.ne t:


Alan Pocklington wrote:
I've created a Java Applet that allows the user to select a record.
As the user makes the selection, the applet uses LiveConnect
(JSObject) to write the record id to a html field (the name of which
is passed in to the applet as an arg).

This all works fine, but now I have two instances of the same applet
running on a page, both linked to different HTML fields so that
making a selection from applet 1 updates html field 1, a selection
from applet 2 updates html field 2. This works for 90% of the time.
However, on the odd occasion one of the applets will write to the
other applet's field (and the other will continue to work normally).
Refresh the page and everything works fine again.

I'm not sure why this is happening and it is driving me crazy! I
wondered if anyone else has run into the same problem.


How do you identify and access the HTML "fields"? Are those form
fields? Is the problem happening with a particular browser?


Jul 23 '05 #3
Nope, the latest netscape.javasc ript.classes still give me the same
problems.

Does anyone have any suggestions?

Alan.

Alan Pocklington <aj*@pocko.free serve.co.uk> wrote in
news:Xn******** **************@ 195.92.193.157:
Hi,

A typical field would be retrieved as a JSObject using the Java method
loadJSTextField shown below, passing in for example document.forms
[0].elements['jobDescription .ID'] as the fieldName.

I then use returnedJSObjec t.setMember("va lue", "newValue") to set the
new value. Reading values is achieved via getMember("valu e");

The problem is occuring in IE6. It doesn't work full stop in Netscape
4.6 but that's another story and it's only a requirement that it works
in IE.

I've just downloaded the lastest netscape.javasc ript.classes in the
hope that this fixes the problem. It's a hard thing to test as, like
I said, it work's 90% of the time, it's just on the odd occasion it
writes to the wrong field.

Any help will be greatly appreciated.
private JSObject loadJSTextField (String fieldName) {
JSObject jsElement;

try {
// Get root.
jsElement = (JSObject) JSObject.getWin dow(this);

// Check for null field name.
if (fieldName == null || fieldName.trim( ).equals(""))
return null;

jsElement = (JSObject) jsElement.eval( fieldName);

// Return reference.
return jsElement;

} catch (Exception jsExp) {
return null;
}
}

Martin Honnen <ma*******@yaho o.de> wrote in
news:40******** @olaf.komtel.ne t:


Alan Pocklington wrote:
I've created a Java Applet that allows the user to select a record.
As the user makes the selection, the applet uses LiveConnect
(JSObject) to write the record id to a html field (the name of which
is passed in to the applet as an arg).

This all works fine, but now I have two instances of the same applet
running on a page, both linked to different HTML fields so that
making a selection from applet 1 updates html field 1, a selection
from applet 2 updates html field 2. This works for 90% of the time.
However, on the odd occasion one of the applets will write to the
other applet's field (and the other will continue to work normally).
Refresh the page and everything works fine again.

I'm not sure why this is happening and it is driving me crazy! I
wondered if anyone else has run into the same problem.


How do you identify and access the HTML "fields"? Are those form
fields? Is the problem happening with a particular browser?



Jul 23 '05 #4

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

Similar topics

1
1837
by: nfalconer | last post by:
I'm writing a Java applet that will call a javascript funciton on the containing page. However, to enable this interaction I need the netscape.javascript java package. Does anyone know where to find this package, I can't find it anywhere. thanks.
1
2073
by: Guillaume CABANAC | last post by:
Hi folks, Is liveconnect still available in Firefox as it is in NS Navigator ? I would like to call Java code from JavaScript in Firefox... Do you think it is possible with liveconnect ? Does a better strategy exists ? I tried to call Java from Javascript like this : var myBook = new Packages.Book() ;
1
1735
by: admin | last post by:
Hi all, I wrote a small text editor (using a JTextPane) in order to ease the use of a CMS, in a more WYSIWYG way. Basically, you can see directly the effect of setting the background color, the text color, bold/italic/underlined styles and so on... You can have several applet on one page as there is one applet per column and per language.
8
3372
by: DKM | last post by:
Here are the source code files to a Java applet that utilizes LiveConnect to communicate with Javascript, and the HTML file. The thing works both in IE 6.0 and FireFox 1.4. but with some problems. IE crashes when one refreshes the page or leave the page. This happens only after calling the Java method more than once. It does not crash if the Java method is called just once and then the page is refreshed. FireFox does not crash at all...
6
7661
by: j_macaroni | last post by:
I am trying to communicate back to my web page using LiveConnect. I just installed JDK5 Netbeans and have created a few applets. I have even called the applets from Javascript. However when I use the import line below it doesnt find the library. I looked for jaws.jar but its not under the Java directory. Does anyone know where it is? Do I have to download it? import netscape.javascript.*;
1
2135
by: Alexandre Lahure | last post by:
Hi all, The facts : a rich text editing applet, a HTML/Javascript toolbar and Liveconnect to make them communicate alltogether. - Java to JS communication (for updating the state of the toolbar - text align, style, color) is OK - JS to Java communication (for changing text align, style, color) doesn't work as expected : * Under Firefox, the first call of a Java method is DAMN SLOW (near 20
0
2418
by: georges the man | last post by:
The purpose: • Sorting and Searching • Numerical Analysis Design Specification You are to write a program called “StockAnalyser”. Your program will read a text file that contains historical price of a stock. The program will allow users to query the stock price of a particular date and output its statistics (mean price, median price and standard deviation) for any specified period. Your program must be menu driven and works as follows.
30
2680
by: Cramer | last post by:
I've finally gotton board with TDD (test driven development) and wow is it effective! I went from sceptic to True Believer with my first effort. My question: According to the various books and articles I have read about TDD, a good unit test does not rely on the database or other such external/environmental conditions. More generally, a good unit test is atomic and makes as few assumptions about its runtime environment as possible. But...
0
8370
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
8283
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8704
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
8470
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
7302
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4147
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...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1591
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.