Creating and using a WebRenderer Server Edition browser instance






When working with a WebRenderer Server Edition browser, the two core interfaces are BrowserFactory and IBrowserCanvas.













Because BrowserFactory spawns instances of the requested browser, BrowserFactory is used to setup the library path (if the WebRenderer platform optimized JAR files are not in the CLASSPATH). The BrowserFactory also manages the license key and font directories for WebRenderer.

Key methods in BrowserFactory:

setLibraryPath(String path)
setLibraryPath(File directory)
setMozillaPath(String path)
setMozillaPath(File directory)
setHomeDirectory(File directory)

If the WebRenderer JAR files are not in the CLASSPATH the library path must be set to the location of the WebRenderer libraries, specifically the webrendererse-xxx.jar (xxx denotes the platform prefix such as win, solaris, linux, osx) and the corecomponentsse-xxx.jar. The webrendererse-xxx.jar and corecomponentsse-xxx.jar can be placed in different directories but if the corecomponentsse-xxx.jar are in a different directory the setMozillaPath and setLibraryPath methods must be called to point WebRenderer to their location.

WebRenderer library search order (if library found searching stops):















The webrendererse.jar must always be in the Java CLASSPATH.

Example (Windows):

java -cp webrendererse.jar; webrendererse-win.jar; corecomponentsse-win.jar;. TestBrowser

setLicenseData(String username, String serial)

The setLicenseData method is essential to enable full WebRenderer functionality. This method must be called before a browser is spawned. If the license information is not set, a dialog will display notifying you and some WebRenderer functionality will be disabled.














loadURL() - The WebRenderer loadURL method is core to loading pages into WebRenderer. The loadURL method can take a URL as a Java String or a java.net.URL.

loadHTML() - WebRenderer's loadHTML is the mechanism used to load HTML and web content into WebRenderer through Java Strings, InputStreams and as Bytes. The loadHTML method takes a base reference as a parameter.

Example usage:

browser.loadHTML("<HTML><B>Hello World</B></HTML>", "");

If an empty base reference is passed to the loadHTML method then the base directory will be the directory the application is loaded from. If there are relative references to images, JavaScript, CSS etc. WebRenderer will search for these in the base reference. The base reference can be a remote URL, it does not necessarily have to be on a local disk. If the base reference is set to a remote URL then WebRenderer will load the resources relative from the passed URL as requested by the document loaded.

setProxyProtocol(ProxySetting protocol, String proxyAddress, int port) - The setProxyProtocol method allows the user to set a proxy server. The proxy server can be an authenticated proxy. For the proxy settings to take effect the IBrowserCanvas enableProxy method must be called. The proxy can be disabled via the disableProxy method.

Example usage:

browser.setProxyProtocol(ProxySetting.PROTOCOL_HTTP, "my.proxy.com", 8080);
// If authenticated proxy
browser.setProxyAuthentication("username", "password");



 Copyright © JadeLiquid Software - www.jadeliquid.com