3 Replies Latest reply: Apr 9, 2010 10:08 AM by 843802 RSS

    Javascript not called with JRE 1.6.0_18 when next-gen plugin enabled

    843802
      Hi all,

      With the latest version, when we use JSObject.getWindow().call(), the javascript is never executed. There's no errors reported, and no exceptions thrown. If we turn off the next-gen plugin, then everything's fine. It affects IE and Chrome, but not Safari (on Windows).

      What I noticed is that the call we make occurs before the message "basic: Told clients applet is started" is output to the Java console - I wonder if that has anything to do with it.

      I just wondered if anyone had any ideas? It's rather hard for us to tell our clients to disable the next-gen plugin (imagine going to every desktop and doing that). We c are going to try using JNLP to force our apps to use an earlier version of the JRE, but it would be useful to understand why it doesn't work.

      Cheers, John
        • 1. Re: Javascript not called with JRE 1.6.0_18 when next-gen plugin enabled
          843802
          We found what was causing the problem. We make an initial call from Java to Javascript to obtain information about the browser. This in turn calls back to Java, which then makes a handful of calls to the Javascript - it's these that are failing. So it seems with 1.6.0_18 and next-gen, you can't call Javascript from within a Java method that's been called from Javascript.

          We put the work that the Java method does into a queue to be processed later and returned to the Javascript. So far, everything's working fine.

          Cheers, john
          • 2. Re: Javascript not called with JRE 1.6.0_18 when next-gen plugin enabled
            843802
            I'm having a similar problem and I think it is related with this.

            If, after a Java--->Javascript call, a Javascript--->Java call isn't made soon after the first, it works. But, if the Java--->Javascript call triggers a Javascript--->Java call, any Java--->Javascript call that is made after that doesn't reach Javascript :/

            I have a method that handles the Java--->Javascript calls and goes something like this:
            System.out.println("Calling Javascript...");
            
            JSObject win = JSObject.getWindow(this);
            
            win.call(jsEventHandler, new Object[] { json.toString() });
            
            System.out.println("Done.");
            I further found out that, after looking at the Java debug console in the scenario where a Java--->Javascript call triggers a Javascript--->Java call, only after this last method returns is the "Done" message printed, even though the respective Javascript call was already invoked.

            Could you explain in more detail the queue based solution you found? Any other ideas?

            Regards,
            André Tavares.
            • 3. Re: Javascript not called with JRE 1.6.0_18 when next-gen plugin enabled
              843802
              I seem to have nailed it with something like this:
              private void sendToJavaScript(String json){
              
                  javascriptQueue.add(json);
              
                  if(javascriptQueue.size() == 1){
              
                      refreshJavascriptQueue();
              
                  }
              
              }
              
              
              
              private void refreshJavascriptQueue(){
              
                  if(!javascriptQueue.isEmpty()){
              
                      String event = javascriptQueue.peek();
              
                      JSObject win = JSObject.getWindow(this);
              
                      win.call(jsEventHandler, new Object[] { event });
              
                      javascriptQueue.poll();
              
                      refreshJavascriptQueue();
              
                  }
              
              }