I'm working with the JDE 7.1 in BrowserField2Demo and want to know how to intercept the "pre-load" event. The "OLD" BrowserFieldDemo had events such as "Event.EVENT_URL_REQUESTED" that would allow URL pre-load manipulations. Where do these events happen with "BrowserField2"?
Example: If the URL requested was "http://www.bing.com/" and I wished to re-direct it to "http://www.google.com/" where does this "pre-load" event happen?
Here is my code after a failed attempt which doesn't work:
private BrowserField _browserField;
private boolean _documentLoaded = false;
private BrowserFieldRequest _request;
/**
* Creates a new BrowserFieldScreen object
* @param request The URI of the content to display in this BrowserFieldScreen
* @param enableScriptMenu True if a context menu is to be created for this BrowserFieldScreen instance, false otherwise
*/
public BrowserFieldScreen(BrowserFieldRequest request, boolean enableScriptMenu)
{
super(Screen.HORIZONTAL_SCROLL);
BrowserFieldConfig config = new BrowserFieldConfig();
config.setProperty(BrowserFieldConfig.ALLOW_CS_XHR, Boolean.TRUE);
config.setProperty(BrowserFieldConfig.JAVASCRIPT_ENABLED, Boolean.TRUE);
config.setProperty(BrowserFieldConfig.NAVIGATION_MODE,BrowserFieldConfig.NAVIGATION_MODE_POINTER);
config.setProperty(BrowserFieldConfig.CONTROLLER, controller);
_browserField = new BrowserField(config);
add(_browserField);
_request = request;
}
ProtocolController controller = new ProtocolController(_browserField)
{
public void handleNavigationRequest(BrowserFieldRequest request) throws Exception
{
InputConnection inputConnection = handleResourceRequest(request);
_browserField.displayContent(inputConnection, request.getURL());
}
};
What I see is that at the first time the handleNavigationRequest
gets called is that it crashes with the error message saying
Error request content for google.com error message null
with a CLOSE button. Then nothing happens.