Rhinohide

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

Rhinohide Ranking & Summary

Advertisement

  • Rating:
  • License:
  • MIT/X Consortium Lic...
  • Price:
  • FREE
  • Publisher Name:
  • Michael Allan
  • Publisher web site:
  • http://zelea.com/project/votorola/

Rhinohide Tags


Rhinohide Description

Rhinohide is a Java implementation of the W3C DOM, layered over a Web browser's native JavaScript. 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 · XML · Events · Traversal · Range Requirements:· Java 1.5 or higherUseDetails 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='' archive='rhinohideDemo.jar' code='textbender/a/b/rhinohideDemo/Test_12D_DOM2.class' MAYSCRIPT='true' width='550' height='90'> < /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 try { 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();}Limitations:· 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 platformsWhat's New in This Release:· Several bugs affecting Internet Explorer were fixed.· Remaining IE bugs were traced and documented.


Rhinohide Related Software