Rhinohide 0.2.0 r2

Rhinohide is a Java implementation of the W3C DOM, layered over a Web browser's native JavaScript.

  Add it to your Download Basket!

 Add it to your Watch List!


Rate it!
send us
an update
MIT/X Consortium License 
Michael Allan
ROOT \ Internet \ HTTP (WWW)
Rhinohide is a Java implementation of the W3C DOM, layered over a Web browser's native JavaScript.

Rhinohide provides an interface for applets to manipulate their containing Web pages, using a standard Java binding of the DOM. The code is still in alpha, and coverage is incomplete, but at least partial support is provided for these DOM features:

· Core level 3
· Events
· Traversal
· Range


· Java 1.5 or higher


Details are in the API docs, and the demo code. What follows is a summary:

In your Web page, there are two encoding requirements. One is to disable in-memory caching, by the browser. (Otherwise inconsistencies of state may occur between JavaScript and Java.)

The second requirement is a mayscript attribute on the applet tag.

The necessary JavaScript and HTML will look something like this, in your Web page:

< script type='text/javascript' >
if( window.addEventListener )
window.addEventListener ( 'unload', // to disable in-memory caching
function( e ) {}, // do nothing
/*capture phase*/false );
< /script >

< applet alt='[applet: unsupported by this browser]'
MAYSCRIPT='true' width='550' height='90'>
[applet: unsupported by this browser]
< /applet >

In your Java applet, your code is mostly ordinary DOM:
private volatile RhiWindow window; // final after init

private final AtomicBoolean isStartedA = new AtomicBoolean();

public void start()
if( isStartedA.getAndSet( true )) return; // start once only

window = RhiWindow.createWindow( /*applet*/this );
final Document document = window.getDocument();

// DOM level 2. see Test_12D_DOM2.java
// ----------------------------------------------------------------------------
assert document.getImplementation().hasFeature( "Core", "2.0" );

Element element = getElementById( document, "parent-of-created" );
Text text = document.createTextNode( "Hello world, from Java" );
element.appendChild( text );

// Events. see Test_22E_Events.java
// ----------------------------------------------------------------------------
assert document.isSupported( "Events", "2.0" );

((EventTarget)document).addEventListener( "mouseover", new RelaySIP()
public void handleEvent( Event e )
// do something
}, /*use capture*/false );

// Traversal. see Test_32T_Traversal.java
// ----------------------------------------------------------------------------
assert document.isSupported( "Traversal", "2.0" );

TreeWalker walker = ((DocumentTraversal)document).createTreeWalker
/*root*/document, NodeFilter.SHOW_ALL,
/*filter*/null, /*expand entities*/false

// Range.
// ----------------------------------------------------------------------------
assert document.isSupported( "Range", "2.0" );

Range myRange = ((DocumentRange)document).createRange();
try // non-standard
Range userSelectedRange = window.getSelection().getRangeAt( 0 );
catch( RuntimeException x ) { assert false; }

catch( StupifiedRhinoException x ) // if the page exits in mid-initialization
Logger.getLogger( getClass().getPackage().getName() )
.info( "page exit in progress? " + x );

public void destroy()
if( window != null ) window.release();


· Many methods are still marked ‘Not yet coded’, and will throw UnsupportedOperationException. (But they can often be implemented in-line, as described below.)
· Testing is incomplete at this stage. And tests often fail, especially on slow machines and/or Windows platforms

What's New in This Release:

· Several bugs affecting Internet Explorer were fixed.
· Remaining IE bugs were traced and documented.

Last updated on June 16th, 2007

#Java implementation #W3C DOM #JavaScript library #Rhinohide #Java #implementation #W3C

Add your review!