diff --git a/mozilla/java/plugins/examples/simple/src/main/web/index.html b/mozilla/java/plugins/examples/simple/src/main/web/index.html index 1cdb8d23071..582c3d37adb 100755 --- a/mozilla/java/plugins/examples/simple/src/main/web/index.html +++ b/mozilla/java/plugins/examples/simple/src/main/web/index.html @@ -116,7 +116,7 @@ var strslen2 = {
-

Code Artifacts

+

Required Code Artifacts

Creating a pluglet requires creating several code arifacts:

@@ -367,33 +367,6 @@ var strslen2 = {
  •     protected void finalize() {
  •         org.mozilla.util.DebugPluglet.print("--SimplePlugletInstance.finalize()\n");
  • -
  •     }
  • -
  •  
  • -
  •     public String calledFromJavaScript3(String arg0, String arg1, String arg2) {
  • - -
  •         org.mozilla.util.DebugPluglet.print("calledFromJavaScript2\n");
  • -
  •         return "3 args.  arg0: " + arg0 + " arg1: " + arg1 + " arg2: " + arg2 + "";
  • - -
  •     }
  • -
  •  
  • -
  •     public String calledFromJavaScript2(String arg0, String arg1) {
  • - -
  •         org.mozilla.util.DebugPluglet.print("calledFromJavaScript2\n");
  • -
  •         return "2 args.  arg0: " + arg0 + " arg1: " + arg1 + "";
  • - -
  •     }
  • -
  •  
  • -
  •     public String calledFromJavaScript1(String arg0) {
  • -
  •         org.mozilla.util.DebugPluglet.print("calledFromJavaScript1\n");
  • - -
  •         return "1 args.  arg0: " + arg0 + "";
  • -
  •     }
  • -
  •  
  • - -
  •     public String calledFromJavaScript0() {
  • -
  •         org.mozilla.util.DebugPluglet.print("calledFromJavaScript0\n");
  • - -
  •         return "0 arg hard coded result";
  •     }
  •  
  •  
  • @@ -562,6 +535,169 @@ var strslen2 = { +

    Calling a Pluglet from JavaScript

    + +

    This release of pluglets allows a limited degree of communication +between JavaScript and the Pluglet class. Through the magic of +Netscape's XPConnect code, it is possible to invoke, from JavaScript in +the page in which the pluglet is embedded, an arbitrary method on +the pluglet, provided the method returns String, and takes +anywhere between zero and ten String arguments. Such a method is +called a "conforming method" for the rest of this +discussion.

    + +

    In the above example, the four plain ole' HTML buttons labeled "Call +Pluglet N arg" (where N is a number between 0 and 3) call a Java method +on the pluglet. Click the Details button on the right to see the +JavaScript code.

    + +
    Details + + +
    + +

    Line 1 is standard JavaScript to get the 0th +<EMBED> element in the page, which happens to be our +pluglet. The functions callPluglet0, +callPluglet1, callPluglet2 and +callPluglet3, declared on lines 3, 16, 29, and 42, +respectively, are called from the onclick handler of the +HTML buttons in the page. Each of these functions calls a Java method +implemented on the pluglet using the special +callPlugletMethod JavaScript function defined on the +XPConnect API for pluglet. The general form of this JavaScript method is:

    + +
    + +
    1. /** The return value of this function is a JavaScript associative array containing
    2. +
    3.   * an entry named 'value', whose value is a JavaScript String that is
    4. + +
    5.   * the Java String returned by the conforming method named in the first argument.
    6. +
    7.   */
    8. +
    9. function callPlugletMethod(<name of a conforming method implemented on Pluglet Class>,
    10. +
    11.                            <JavaScript associative array containing an
    12. + +
    13.                            entry named 'value', whose value is
    14. +
    15.                            JavaScript array (of length zero thru ten) of
    16. + +
    17.                            JavaScript strings.  Each element in the
    18. + +
    19.                            array will be passed to the corresponding
    20. +
    21.                            String argument in the conforming method.>,
    22. + +
    23.                            <JavaScript associative array containing an
    24. +
    25.                            entry named 'value', whose value is a
    26. + +
    27.                            JavaScript number representing the length of
    28. +
    29.                            the array.>);
    + +

    The Java code for the methods calledFromJavaScriptN +(where N is a number between 0 and 3) can be seen by expanding the +Details button on the right. These methods are defined on the class +SimplePlugletInstance.

    + +
    Details +
    + +

    NOTE: One convenient interchange format would be to return JSON strings from your conforming methods.

    diff --git a/mozilla/java/plugins/examples/style/bg.gif b/mozilla/java/plugins/examples/style/bg.gif index 21a9ee1767e..bc7a594d5fb 100755 Binary files a/mozilla/java/plugins/examples/style/bg.gif and b/mozilla/java/plugins/examples/style/bg.gif differ diff --git a/mozilla/java/plugins/examples/style/inner.bg.bl.gif b/mozilla/java/plugins/examples/style/inner.bg.bl.gif new file mode 100755 index 00000000000..a6fdf67b9e8 Binary files /dev/null and b/mozilla/java/plugins/examples/style/inner.bg.bl.gif differ diff --git a/mozilla/java/plugins/examples/style/inner.bg.br.gif b/mozilla/java/plugins/examples/style/inner.bg.br.gif new file mode 100755 index 00000000000..9ebac9481ae Binary files /dev/null and b/mozilla/java/plugins/examples/style/inner.bg.br.gif differ diff --git a/mozilla/java/plugins/examples/style/inner.bg.tl.gif b/mozilla/java/plugins/examples/style/inner.bg.tl.gif new file mode 100755 index 00000000000..bae8ca8adf8 Binary files /dev/null and b/mozilla/java/plugins/examples/style/inner.bg.tl.gif differ diff --git a/mozilla/java/plugins/examples/style/inner.bg.tr.gif b/mozilla/java/plugins/examples/style/inner.bg.tr.gif new file mode 100755 index 00000000000..dbb10eff1ee Binary files /dev/null and b/mozilla/java/plugins/examples/style/inner.bg.tr.gif differ diff --git a/mozilla/java/plugins/examples/style/page_white_code.gif b/mozilla/java/plugins/examples/style/page_white_code.gif index ce26476c86f..147e9ed1f88 100755 Binary files a/mozilla/java/plugins/examples/style/page_white_code.gif and b/mozilla/java/plugins/examples/style/page_white_code.gif differ diff --git a/mozilla/java/plugins/examples/style/page_white_code_red.gif b/mozilla/java/plugins/examples/style/page_white_code_red.gif index 3435c350fe9..6b74e5445b8 100755 Binary files a/mozilla/java/plugins/examples/style/page_white_code_red.gif and b/mozilla/java/plugins/examples/style/page_white_code_red.gif differ diff --git a/mozilla/java/plugins/examples/style/screen.css b/mozilla/java/plugins/examples/style/screen.css index 00e7d9223ee..8e98de531bd 100755 --- a/mozilla/java/plugins/examples/style/screen.css +++ b/mozilla/java/plugins/examples/style/screen.css @@ -112,12 +112,12 @@ h4 a { width: 100%; } #example:before { - background: transparent url(win.bg.tr.gif) scroll no-repeat top right; + background: transparent url(inner.bg.tr.gif) scroll no-repeat top right; margin-bottom: -30px; height: 30px; display: block; border: none; - content: url(win.bg.tl.gif); + content: url(inner.bg.tl.gif); padding: 0; line-height: 0.1; font-size: 1px; @@ -135,9 +135,9 @@ h4 a { line-height: 0.1; font-size: 1px; text-align: left; - content: url(win.bg.bl.gif); + content: url(inner.bg.bl.gif); background: white; - background: transparent url(win.bg.br.gif) no-repeat bottom right; + background: transparent url(inner.bg.br.gif) no-repeat bottom right; padding: 0; } @@ -311,3 +311,21 @@ div.syntax a .java .nu0 {color: #cc66cc;} .java .me1 {color: #006600;} .java .me2 {color: #006600;} + +/* GeSHi (c) Nigel McNie 2004 (http://qbnz.com/highlighter) */ +.javascript .de1, .javascript .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;} +.javascript {font-family: monospace;} +.javascript .imp {font-weight: bold; color: red;} +.javascript li {background: #ffffff;} +.javascript li.li2 {background: #f8f8f8;} +.javascript .kw1 {color: #000066; font-weight: bold;} +.javascript .kw2 {color: #003366; font-weight: bold;} +.javascript .kw3 {color: #000066;} +.javascript .co1 {color: #009900; font-style: italic;} +.javascript .coMULTI {color: #009900; font-style: italic;} +.javascript .es0 {color: #000099; font-weight: bold;} +.javascript .br0 {color: #66cc66;} +.javascript .st0 {color: #3366CC;} +.javascript .nu0 {color: #CC0000;} +.javascript .me1 {color: #006600;} +.javascript .re0 {color: #0066FF;} diff --git a/mozilla/java/plugins/examples/style/win.bg.bl.gif b/mozilla/java/plugins/examples/style/win.bg.bl.gif index c9897f6d795..85dff5dabf9 100755 Binary files a/mozilla/java/plugins/examples/style/win.bg.bl.gif and b/mozilla/java/plugins/examples/style/win.bg.bl.gif differ diff --git a/mozilla/java/plugins/examples/style/win.bg.br.gif b/mozilla/java/plugins/examples/style/win.bg.br.gif index 8c5fa4a4133..c8a91f4065a 100755 Binary files a/mozilla/java/plugins/examples/style/win.bg.br.gif and b/mozilla/java/plugins/examples/style/win.bg.br.gif differ diff --git a/mozilla/java/plugins/examples/style/win.bg.tl.gif b/mozilla/java/plugins/examples/style/win.bg.tl.gif index 8c223a1e9fd..79a608aadfe 100755 Binary files a/mozilla/java/plugins/examples/style/win.bg.tl.gif and b/mozilla/java/plugins/examples/style/win.bg.tl.gif differ diff --git a/mozilla/java/plugins/examples/style/win.bg.tr.gif b/mozilla/java/plugins/examples/style/win.bg.tr.gif index 15b03f2f362..82eb4e9296a 100755 Binary files a/mozilla/java/plugins/examples/style/win.bg.tr.gif and b/mozilla/java/plugins/examples/style/win.bg.tr.gif differ