rhino

XMLHttpRequest Implementation

I would like to understand the low level details of how XMLHttpRequest works in Javascript, however I have not had any luck finding the implementation code within either the Rhino or V8 code. I'm not familiar with the code in either projects, so I may not be looking in the right spots. Is there an available open-source implementation a...

Useful, small support toolkit for using Rhino with Java (via the scripting framework)?

Using the scripting framework (javax.script.*), it's really easy to get basic integration between Java and Javascript working. However, once you get to the point of wanting to do something really useful, you run into all the little ways that the bridge from Javascript back to Java (and, to some extent, the other direction too) are messy....

Is it possible to communicate stuff from Rhino up to Java via an exception?

Using the JDK 6 ScriptEngine mechanism, anything that goes wrong during an "eval" or "invokeMethod" or whatever results in a ScriptException being thrown back to the invoking Java environment. As far as I've been able to tell by experimentation and source code reading, the best I can do to get information back from Javascript when my Ja...

Why can't Javascript (running in Rhino) access methods on a java.lang.reflect.Method instance?

Here's a very simple example of what I see: jrunscript -f - js> var d = new java.util.Date(); js> var m = d.getClass().getMethods(); js> println(m[0].getClass().getName()); java.lang.reflect.Method js> var name = m[0].getName(); script error: sun.org.mozilla.javascript.internal.WrappedException: Wrapped java.lang.UnsupportedOperationExc...

asp.net mvc rhino mocks mocking httprequest values

Hi Is there a way to mock request params, what is the best approach when testing to create fake request values in order to run a test would some thing like this work? _context = MockRepository.GenerateStub<HttpContext>(); request = MockRepository.GenerateStub<HttpRequest>(); var collection = new NameValueColle...

Non-terminating RegExp.exec in Rhino

I have the following JavaScript program saved in a file pre.js: var pre = readFile("method-help.html"); RegExp.multiline = true; print(/<pre>((?:.|\s)+)<\/pre>/.exec(pre)[1]); The contents of method-help.html is simply the page at http://api.stackoverflow.com/1.0/help/method?method=answers/%7bid%7d. What I'm trying to do is get the J...

A faster way to execute javascript code within Java(sdk1.4)

Currently, I am using Rhino engine to execute some big blocks of javascript code on the server side. However, sometimes, it takes so long(more than 10 minutes) and eat up all CPU usage (at least on my local development env, it is doing this right now). So I am wondering that what I can do to improve the current system or I can try a new...

Rhino Mocks and Visual Studio: How do I fix this error?

I'm having another fun problem with Rhino Mocks. Can anyone answer this one: Here's the call that I'm making in my code: Expect.On(this.mockDal).Call(this.mockDal.SaveObject(entry)).IgnoreArguments(); mockDal is mocking something of type Dal, and it's SaveObject method's signature is this; void SaveObject(object obj); Visual Stud...

Help me avoid this NullReferenceException (using Rhino Mocks)

I'm currently trying to get one of my unit tests to work, but there is one thing in the way. I have a class called AccountingScheduleLookup that has an ID field attached to it that's read-only. When I try to mock a call to a method that uses this ID field it throws me a lovely NullReferenceException on that particular line of code. This ...

Why not Rhino for JVM apps?

I would like to develop some apps for the JVM using a concise, dynamic language. The most popular choices for this seem to be Jython, JRuby, Groovy, and maybe Clojure. Rhino appears to be fast and very stable, but I see no books on Rhino development and little discussion. Why is there apparently little use of JavaScript for other than e...

How to add Rhino Javascript 1.7 library to classpath in Weblogic 10

Weblogic packages rhino classes inside weblogic.jar. I need newer version of rhino js.jar. If I just distribute the newer rhino js jar like any other third party jar, it does not get loaded, because the older classes inside weblogic.jar are loaded first. How can I load classes from my custom js.jar in weblogic 10? ...

Does throwing exception in JS property assignment in Rhino makes sense?

I came across a design that overrides [Scriptable.put][1] in a subclass of ScriptableObject to do some conversion. If the conversion fails the code is throwing an exception. Which means that property assignments like following code can cause a runtime exception to be thrown aScriptable.dateOfArrival = aVar; By default rhino would...

Does Java 6 include a program that can run javax.script (Rhino JS) files?

I found that Java 6 includes Rhino JS (except for one or two minor pieces), as javax.script. Pretty cool! Does a Java 6 install (JRE or JDK, either) contain a binary that I can simply point to a .js file to run? (I think it would be great to be able to provide source code for others to read and run, without compilation, and require on...

Rhino, e4x and generating URLs in XHTML

I'm using Rhino to generate XHTML but my urls are being encoded as in: -http://www.example.com/test.html?a=b&amp;c=d becomes -http://www.example.com/test.html?a=b&amp;amp;c=d Failing test case as follows: public class E4XUrlTest extends TestCase { public void testJavascript() throws Exception { final Context context = ne...

how do you get the path of the javascript file run through the rhino shell commandline

how do you get the path of the javascript file run through the rhino shell commandline? eg: java -jar js.jar /path/to/this/file.js i would like to get /path/to/this/file.js, any ideas? ...

How can I reduce this scripting code.

Here is sample code. package base; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class Test { int value1; ScriptEngine engine; public Test(){ this.engine = new ScriptEngineManager().getEngineByName("js"); this.engine.put("p",this); ...

Why doesn't jrunscript honor my classpath?

I'm trying to do some JDBC access from JavaScript using the Rhino included in Java 6. But I cannot make the DriverManager find the Driver I want to use. These two examples should be equivalent: Java: public class DbTest { public static void main(String[] argv) { java.sql.Connection c = null; try { java....

Programatically generate PNG from Raphael.JS image

I'm writing an app that lets users generate images with Raphael.JS. One of the secondary features I want is to generate a PNG of the Raphael canvas. Here's the general pipeline in my head: User inputs parameters We generate JS with Raphael calls We generate a JS wrapper that does the above and calls .innerHTML on the containing div, ...

How can one know if a property is an array?

Hi there, I am calling a JavaScript function using the rhino API: Function fct = context.compileFunction(scope, script, "script", 1, null); Scriptable result = (Scriptable) fct.call( context, scope, attrs, new Object[0]); Object obj = result.get("objectClass", result); Now, how can I test if the value of the "objectClass"...

can rhino parse HTML files

Can rhino parse full HTML file with JS in it ? ...