Created
January 10, 2012 19:09
-
-
Save dpruessner/1590560 to your computer and use it in GitHub Desktop.
JRuby DOM connection (start)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hi-- | |
Here's how (I believe) you can modify Web DOM within JRuby: | |
1) Modify jruby/src/org/jruby/JRubyApplet.java: | |
409a410,413 | |
> final IRubyObject wrappedApplet = JavaEmbedUtils.javaToRuby(runtime, applet); | |
> runtime.defineGlobalConstant("JRUBY_APPLET", wrappedApplet); | |
> wrappedApplet.getMetaClass().defineAnnotatedMethods(RubyMethods.class); | |
> | |
This will allow the console-based IRB session to have access to the | |
JRUBY_APPLET-- not just the non-console-based applet. | |
2) | |
jso = Java::NetscapeJavascript::JSObject.getWindow(JRUBY_APPLET) | |
doc = jso.getMember 'document' | |
loc = jso.getMember 'location' | |
loc.getMember 'href' #=> "http://...." | |
Useful links: | |
http://docs.oracle.com/javase/1.4.2/docs/guide/plugin/developer_guide/java_js.html | |
http://www.rgagnon.com/javadetails/java-0172.html | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment