ABOUT US

|

SUPPORT

|

BLOG

DOWNLOADS    

 

 

 

 


 

 

Capturing network and browser activity

 

 

 

 

 

 

WebRenderer supports a complete set of events that provide for the capturing of many different browser and network related activities. The com.webrenderer.event package is the package containing all WebRenderer event classes.

BrowserEvents

The BrowserEvent is the class that supplies all browser interface related events (navigation, link and title change etc.). Two key methods in the BrowserListener interface are the onBeforeNavigate and the onLoadIntercept methods. The onBeforeNavigate method is fired when navigation is occuring. Through onBeforeNavigate the URL and POST information are made available. onLoadIntercept is fired before a URL navigation begins and provides the opportunity to block the URL load (e.blockLoad). Because of the timing in which this event is fired POST information is not available.

The BrowserListener interface:

onBeforeNavigate is fired as WebRenderer navigates to a page. This event can be fired as a result of clicking on a link, or by JavaScript executing in a page, or through WebRenderer calls such as loadURL. onBeforeNavigate is used to signal the start of a transaction from page to page.

Example usage:
 
Browser.addBrowserListener(new BrowserAdapter() {
        public void onBeforeNavigate(BrowserEvent e) {
                // Page navigation occurring
        }
});

        
onLoadIntercept is much like the onBeforeNavigate method with the exception that it can block the load of a page. This method is useful in filtering URL loads to any set criteria such as domain specific.
 
Example usage:
 
browser.addBrowserEvent(new BrowserAdapter() {
        public void onLoadIntercept(BrowserEvent e) {
                if(e.getURL().contains("jadeliquid.com")) {
                        // Blocking the load of the URL
                        e.blockLoad();
                }
        }
});


If the blockLoad method is not called the page will load as normal after the onLoadIntercept method returns.

Other methods available through the NetworkListener

// Deprecated. Use MouseListener
void onContextMenu(BrowserEvent e)

// Invoked when the link message changes in a browser
void onLinkChange(BrowserEvent e)
 
// Invoked when the loading of a URL is prematurely stopped
void onNavigationCancelled(BrowserEvent e)
 
// Invoked when the title changes in a browser
void onTitleChange(BrowserEvent e)
 
// Invoked when the URL changes in a browser
void onURLChange(BrowserEvent e)

NetworkEvents

The NetworkEvent class supplies all network transaction activity and page load status. The NetworkEvent class contains the single most important event in the WebRenderer package; the onDocumentComplete(NetworkEvent e). onDocumentComplete signals the completion of a document load and signals when browser and DOM related "get" methods become populated.

Example:


browser.addNetworkListener(new NetworkAdapter() {
        public void onDocumentComplete() {
// Document has completed loading fire manipulation
        }
});


Other useful NetworkEvents include:

// Invoked when a document stops loading in a browser
onDocumentComplete(NetworkEvent e)  

// Invoked when a document starts loading in a browser.
onDocumentLoad(NetworkEvent e)

// Invoked from an IBrowserCanvas when before a HTTP request is sent.
onHTTPInterceptHeaders(NetworkEvent e)

// Invoked from an IMozillaBrowserCanvas when Http Response data is sent back from a request.
onHTTPResponse(NetworkEvent e)

// Invoked when an error occurs on the network.
onNetworkError(NetworkEvent e)

// Invoked when the status of the network has changed.
onNetworkStatus(NetworkEvent e)

// Invoked when the progress of a document download changes.
onProgressChange(NetworkEvent e)

If any of the WebRenderer events are not firing please see the section on the
WebRenderer license dialog

 

 

 

 

 

Copyright © JadeLiquid Software - www.jadeliquid.com