|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ProtocolListener
The listener interface for receiving requests for your own custom protocol implementations.
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 invokations 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 Requst 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
IMozillaBrowserCanvas.registerProtocol(java.lang.String, com.webrenderer.se.event.ProtocolListener)
,
ProtocolEvent
Method Summary | |
---|---|
void |
onOpen(ProtocolEvent e)
Invoked when the browser needs to load a url of the registered protocol. |
Method Detail |
---|
void onOpen(ProtocolEvent e)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |