test/script/sandbox/javaextend.js

changeset 23
2a5c2258827b
parent 7
5a1b0714df0e
child 27
eda69555239a
equal deleted inserted replaced
22:0362d36d3dd6 23:2a5c2258827b
96 96
97 // Subclass a class with a protected constructor, and one that takes 97 // Subclass a class with a protected constructor, and one that takes
98 // additional constructor arguments (a token). Also demonstrates how can 98 // additional constructor arguments (a token). Also demonstrates how can
99 // you access the Java adapter instance from the script (just store it in the 99 // you access the Java adapter instance from the script (just store it in the
100 // scope, in this example, "cwa") to retrieve the token later on. 100 // scope, in this example, "cwa") to retrieve the token later on.
101 var cwa = new (Java.extend(model("ConstructorWithArgument")))(function() { print(cwa.token) }, "cwa-token") 101 var cwa = new (Java.extend(model("ConstructorWithArgument")))("cwa-token", function() { print(cwa.token) })
102 cwa.doSomething() 102 cwa.doSomething()
103
104 // Do the same thing with proprietary syntax and object literal
105 var cwa2 = new (model("ConstructorWithArgument"))("cwa2-token") { doSomething: function() { print("cwa2-" + cwa2.token ) } }
106 cwa2.doSomething()

mercurial