rhino

How do you return an exit code from Rhino?

I'm using java to run a command line utility written in Rhino but if there is an error I need to return that error back to the shell so processing stops. How do I pass back an error code from Rhino to the shell? ...

Java ScriptEngine: using value on Java side ?

In a Java program I'm invoking a user-defined JavaScript program: File userJSFile=...; javax.script.ScriptEngineManager mgr=new ScriptEngineManager(); javax.script.ScriptEngine scripEngine= mgr.getEngineByExtension("js"); Object result=scripEngine.eval(new java.io.FileReader(userJSFile)); Now I would like to use 'result': how can I h...

Mozilla Rhino: Default JavaScript Compliance Level

Hi there, to execute JavaScript in Rhino one has to create an execution context for the script. The constructor of the Context class uses the JavaScript compliance level VERSION_DEFAULT. protected Context(ContextFactory factory) { if(factory == null) { throw new IllegalArgumentException("factory == null"); } this.fa...

How can I add an object property to the global object in rhino javascript

I have some properties in an object that I would like to add to the global namespace. In javascript on the browser I could just add it to the window object like so: var myObject = { foo : function() { alert("hi"); } // and many more properties }; for (property in myObject) { window[property] = myObject[property]; } // now ...

How do I enable logging in RhinoETL process?

I have nearly completed my first ETL process that uses Rhino ETL, and I've been able to figure out the way to use the API by referring to the tests. Great. I have data moving through the pipeline and being written to the db. However I can't seem to figure out how to enable logging. the log4net assemblies are there, the log4net object...

How can I define static properties for Rhino's ScriptableObject?

Rhino provides Scriptable interface and ScriptableObject helper class to implement a javascript object backed by a java object. When ScriptableObject is constructed, its methods with names starting with jsFunction___, jsStaticFunction___, jsGet___, jsSet___, jsConstructor are automatically defined for the javascript object. This way yo...

Rhino Igloo vs. WCSF

Hi All, I'm trying to implement the MVP pattern on web forms. I have two options to go with, Rhino Igloo and WCSF. Which way you recommend to go with. BTW, ASP.NET MVC or MonoRails is not an option in my case. Cheers, ...

How to use mozilla Rhino behind firewall?

Normally if I run the following the following command in the rhino shell, mbp001:rhino1_7R2 user$ java -jar js.jar Rhino 1.7 release 2 2009 03 22 js> readUrl("http://www.google.com") It will return the resultant html markups. However, if I runs it behind a firewall, it will throw an exception (because it is unable to reach the host)...

Odd save behaviour with NHibernate and Rhino Repositories

I am experiencing some odd behaviour with NHibernate. I'm retrieving a list of Learners from a repository, updating them as necessary, the odd thing is when I save the first one, the changes made to all the learners are being commited to the database. [Transaction] public void UpdateLearner(Learner learner) { ...

RhinoMocks exceptions when stubbing out Equals method

Hi! I've a problem setting up a test for an Equals method on an object. The object in question is defined by this interface: public interface IHours { ITimeOfDay OpenAt { get; set; } ITimeOfDay CloseAt { get; set; } DateTime ValidFrom { get; set; } DateTime ValidTo { get; set; } bool isCovered(DateTime time); } a...

How to convert Rhino-JavaScript arrays to Java-Arrays

I have the following: ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine jsEngine = mgr.getEngineByName("JavaScript"); jsEngine.eval("function getArray() {return [1,2,3,4,5];};"); Object result = jsEngine.eval("getArray();"); How can i convert the result object which is of type sun.org.mozilla.javascript.internal.Native...

Is there a way to test Comet applications without a running browser?

I'm trying to connect to an application that uses Comet and is pretty heavy on Javascript and Comet. I've gone as far as I can go in Firebug, HTTP Header examination and am trying to see what's coming over the wire by writing something using Ruby Mechanize. However, since I have no client run-time, my approach is to mimic the HTTP re...

Advantages of using Rhino (mozilla's rhino)

I've been reading about Rhino as a useful way to implement JavaScript inside my Java code. After reading for a while, searching in google and here, I couldn't find a real reason for which I would use JavaScript inside Java. Could you point some real world advantages you find on using Rhino for a regular Java application? ...

How to best install Rhino on OSX 10.6 Snow Leopard

I am running OSX 10.6 Snow Leopard, have downloaded rhino1_7R2 and moved it to /usr/local/ I am aware however that (while this would prevent it from being altered by OS updates) this may not be the best location for it and imagine that it may need to be connected to the Java installation. My intended use for Rhino is to run JavaScript ...

JSP java2d JSP 2d Taglib - Rhino gives me an error

Hi! I'm trying to draw simple 2d things in my JSP application. I found this taglib on http://ditchnet.org/2d/ but it doesn't work as expected... If I start my webapp I get the following error: org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 20 17: 18: Hello World...

Exposing a function from Java to Rhino

It's easy to make objects available to Rhino from Java using ScriptableObject.putProperty, but is there a way to expose a top-level function? That is, can I make it so scripts in Rhino can call foo() and have that call out to Java code? ...

Rhino Javascript:

I am utilizing the javax.scripting with Rhino in this project. I have a Java method that returns a Java Object (Double, Long, Integer, etc). I want to call that method from javascript and reference the result as a Javascript primitive type. However, javacript recognizes the return type as an Object. How do I force it to convert...

JavaScript / Rhino: Can I use a regular expression in an E4X query to select certain nodes only?

Hi! I'm working on Rhino (Mirth), and I've got to process / parse an XML with the following structure: <root> <row> <foo-1 /> <foo-2 /> <foo-3 /> <foo-4 /> ... <bar-1 /> <bar-2 /> <bar-3 /> <bar-4 /> ... <something-else-1 /> <something-else-2 /> </row> </root> I want to get all the "foo" nodes only, avoiding the use of loops if possi...

Problem with Rhino-Etl and MySQL

I've been using Rhino-ETL for a little while and it's running pretty smooth. However I have a problem connecting to my MySQL DB. Rhino.Etl.Core.RhinoEtlException: Failed to execute operation Hornalen.Migration .Process.ReadMessagesFromDb: The type name 'MySql.Data.MySqlClient' could not be found for connection string: testConnectionStr...

Custom class loader in Constructor.newInstance

I'm using rhino via the bean scripting framework to create and configure objects in my java process. Some of the classes used in the scripts need to be loaded dynamically as they won't always be on the standard classpath. To load these classes I initialize the scripting framework's context factory with a custom class loader that loads t...