public interface ProtocolListener extends EventListener
The class that is interested in processing a Protocol event implements this interface (and all the methods it contains).
The listener object created from that class is then registered with an
IMozillaBrowserCanvas
using the registerProtocol method.
The onOpen method is invoked when the browser needs to load a resource from a protocol that this is registered for. This method always invoked in a new Thread so multiple invocations of onOpen can happen simultaneously.
Example of use the "hello:" protocol
IMozillaBrowserCanvas browser = BrowserFactory.spawnMozilla();
browser.registerProtocol( "hello", new ProtocolListener() {
public void onOpen( ProtocolEvent e ) {
String url = e.getURL();
//Start Request with content type text/html
e.onStartRequest( "text/html" );
//Send the data through, this can be called as many times as needed while data becomes available
e.onDataAvailable(("<B>Hello</B> World: <EM>" +url.substring(url.indexOf(":")+1,url.length()) +"</EM>"). getBytes());
//Tell the browser we are finished and everything went ok.
e.onStopRequest(ProtocolEvent.REQUEST_OK);
}
});
Loading the url "hello:John" will show :
Hello World: John
Modifier and Type | Method and Description |
---|---|
void |
onOpen(ProtocolEvent e)
Invoked when the browser needs to load a url of the registered protocol.
|
void onOpen(ProtocolEvent e)