473,394 Members | 1,843 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,394 software developers and data experts.

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 1504


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 returnedJSObject.setMember("value", "newValue") to set the new
value. Reading values is achieved via getMember("value");

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.javascript.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.getWindow(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*******@yahoo.de> wrote in
news:40********@olaf.komtel.net:


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.javascript.classes still give me the same
problems.

Does anyone have any suggestions?

Alan.

Alan Pocklington <aj*@pocko.freeserve.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 returnedJSObject.setMember("value", "newValue") to set the
new value. Reading values is achieved via getMember("value");

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.javascript.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.getWindow(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*******@yahoo.de> wrote in
news:40********@olaf.komtel.net:


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
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...
1
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...
1
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...
8
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...
6
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...
1
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...
0
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...
30
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...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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...
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
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...

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.