LiveConnect writing to wrong field.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alan Pocklington

    #1

    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.
  • Martin Honnen

    #2
    Re: LiveConnect writing to wrong field.



    Alan Pocklington wrote:
    [color=blue]
    > 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.[/color]

    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/

    Comment

    • Alan Pocklington

      #3
      Re: LiveConnect writing to wrong field.

      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 <mahotrash@yaho o.de> wrote in
      news:4083bec3$1 @olaf.komtel.ne t:
      [color=blue]
      >
      >
      > Alan Pocklington wrote:
      >[color=green]
      >> 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.[/color]
      >
      > How do you identify and access the HTML "fields"? Are those form
      > fields? Is the problem happening with a particular browser?
      >[/color]

      Comment

      • Alan Pocklington

        #4
        Re: LiveConnect writing to wrong field.

        Nope, the latest netscape.javasc ript.classes still give me the same
        problems.

        Does anyone have any suggestions?

        Alan.

        Alan Pocklington <ajp@pocko.free serve.co.uk> wrote in
        news:Xns94D08AC 615336ajp10304@ 195.92.193.157:
        [color=blue]
        > 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 <mahotrash@yaho o.de> wrote in
        > news:4083bec3$1 @olaf.komtel.ne t:
        >[color=green]
        >>
        >>
        >> Alan Pocklington wrote:
        >>[color=darkred]
        >>> 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.[/color]
        >>
        >> How do you identify and access the HTML "fields"? Are those form
        >> fields? Is the problem happening with a particular browser?
        >>[/color]
        >
        >[/color]

        Comment

        Working...