我正在 BrowserField2Demo 中使用 JDE 7.1,想知道如何拦截“预加载”事件。“OLD” BrowserFieldDemo 具有诸如“Event.EVENT_URL_REQUESTED”之类的事件,这些事件将允许 URL 预加载操作。“BrowserField2”在哪里发生这些事件?
示例:如果请求的 URL 是“ http://www.bing.com/ ”并且我希望将其重新定向到“ http://www.google.com/ ”这个“预加载”事件在哪里发生?
这是我在尝试失败后的代码,但它不起作用:
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());
}
};
我看到的是,第一次handleNavigationRequest
被调用的是它崩溃并显示错误消息
google.com 错误消息的错误请求内容 null
带有关闭按钮。然后什么也没有发生。