Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8013173

Sample for invoking applet methods from JavaScript needs to be updated

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 7u25
    • 7u21
    • docs
    • None
    • Not verified

      Support for per-applet Package keywords was removed for 7u21. A sample in the Java Tutorials used this (http://docs.oracle.com/javase/tutorial/deployment/applet/examples/dist/applet_InvokingAppletMethodsFromJavaScript/AppletPage.html) and must be updated to work without the Package keyword:

      Basically wherever <applet>.Packages was used will have to be replaced with an actual method or field in the applet that provides access to whatever class or method that JavaScript was trying to use.

      So these:
              // "Packages" keyword; check Java console log
              // for this message
              mathApplet.Packages.java.lang.System.out.
                  println("Testing printing to System.out");

              // Set static field using "Packages" keyword;
              // static methods may be similarly invoked
              mathApplet.Packages.jstojava.DateHelper.label =
                  "Today\'s date is: ";

              // Create an instance of a class and invoke
              // method using "Packages" keyword
              var dateHelper =
                  new mathApplet.Packages.jstojava.DateHelper();
              var dateStr = dateHelper.getDate();


      would need to change to something like:
              // check Java console log for this message
              mathApplet.printOut("Testing printing to System.out"); // or just removed really

              // Set applet field
              // methods may be similarly invoked
              mathApplet.dateHelperLabel = "Today\'s date is: ";

              // Create an instance of a class and invoke
              // method using "Packages" keyword

              var dateHelper = mathApplet.getDateHelper();
              var dateStr = dateHelper.getDate();

      then the corresponding fields and methods added to the applet itself.

            jgordon Joni Gordon (Inactive)
            jgordon Joni Gordon (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: