The Browser Window is shown in a Netbeans TopComponent and generally works just fine.
However I have several rather small, but nasty Bugs that I noticed which are always following the same pattern:
Whatever Code I execute that concerns the jcef Browser always only works when I execute it a second time and is all but ignored the first time around.
However there are no error messages or logs or any thing like that and the code seems to be executed when I go through it with the debugging tool.
I currently believe the problem might lie in Netbeans RCP and jcef working together.
I searched for similar problems on this forum but came up with nothing useful.
Three examples:
1. Implementing a return button: This just checks whether the CefBrowser Instance returns true for browser.canGoBack(). If it returns true a Button is activated. And whilst the return from canGoBack() is correct all the time, it activates the Button just after the second time that this function returns true. From there on out it works just fine.
2. Implementing a "go to" function: This function just takes you to a specified other website than the startpage. Again works fine from the 2nd time onwards, but the first time the code is simply ignored. (although I confirmed via Debugger that the code is executed without errors even the first time around)
3. Implementing a Login Dialog: If the browser notices that Authentication is required, this opens up a Dialog where the user can enter BASIC Credentials. And again the dialog gets opened, the credentials are returned correctly (confirmed via Log), are handed over to the appropriate function and it works for the second try but not the first. (credentials were identical) Indeed I confirmed via Wireshark, that the first time that callback.Continue(ad.getUsername(), ad.getPassword()); is executed, nothing at all is actually send to the server....
Code for the third example:
- Code: Select all
cefClient_.addRequestHandler(new CefRequestHandlerAdapter() {
@Override
public boolean getAuthCredentials(CefBrowser browser, String origin_url, boolean isProxy, String host,
int port, String realm, String scheme, CefAuthCallback callback) {
AuthenticationDialog ad = new AuthenticationDialog();
ad.authenticate(); // Shows Login Dialog
LOGGER.log(Level.INFO, String.format("--->%s:%s", ad.getUsername(), ad.getPassword())); //This confirms that the variables are indeed correct even the first time around
callback.Continue(ad.getUsername(), ad.getPassword());
return true;
}
});
Sadly I don't have any clue anymore what could possibly cause these problems.
If anyone of you has had these same problems or has any idea as to how to fix them or even where to start looking for a fix I would very much appreciate your comments.
Thanks in advance!