rhino

Passing Class<?> parameter using Rhino

Hello, I am trying to call a constructor for a custom collection object. This custom object takes in a parameter of type Class. In java, this is done like this: ICollection col = new PersistentCollection(ContentX.class); This is my first dive into rhino, and I haven't been able to figure out quite how to pass this parameter. I figur...

Rhino: How to call JS function from Java

I'm using Mozilla Rhino 1.7r2 (not the JDK version), and I want to call a JS function from Java. My JS function is like this: function abc(x,y) { return x+y } How do I do this? Edit: (The JS function is in a separate file) ...

Equivalent of Ruby's "require" in Javascript

How do you "require" another file into the existing file in Javascript? Is there anything similar to Ruby's "require" or "load"? > Note: I'm using JS in server (Rhino) Reason: I just need to access the methods in the other JS files. Update: This works only when executing it from cmd line. When I try to call it programatically it fail...

Rhino: Prototype chaining not working for host objects?

Invoking on a child a method defined in parent, where parent is a host object, gives EcmaError: method called on incompatible object. Host object defined in Java: public class HostObject extends ScriptableObject { public HostObject() {} @Override public String getClassName() { return "HostObject"; ...

Rhino: How to return a string from java to javascript?

enter code hereHow do I use Rhino return a string from java to javascript, all I get is org.mozilla.javascript.JavaNativeObject when I use var jsString = new java.lang.String("test"); inside my js file. Is this the right way to do it? var jsString = String(new java.lang.String("test")); PS. The goal is to have a java method to ret...