2

I have an WebView object which I have added a popup handler to as so:

WebView view = new WebView();
WebEngine engine = view.getEngine();

engine.setCreatePopupHandler(new Callback<PopupFeatures, WebEngine>() {

    public WebEngine call(PopupFeatures param) {

        Stage stage = new Stage(StageStyle.UTILITY);
        WebView popupView = new WebView();

        stage.setScene(new Scene(popupView));
        stage.show();

        return popupView.getEngine();

     }

});

This works as intended when a typical web page is loaded such as http://www.google.com. Where I run into trouble is when a URI meant to be passed to Windows command line is opened by JavaScript. Particularly I am trying to start a lync conference call by passing "conf:sip..." to the command line:

window.open("conf:sip...")

I know that WebView isn't capable of loading a location like this and that isn't the main issue. I can catch a MalformedURLException and then pass command myself. What is the issue is that the popup handler never seems to pass the destination on. I have tried adding a listener to the locationProperty and the workDoneProperty as well as an onError listener to both the original engine and the popupView engine. The popup appears to never be passed the destination of the window.open function and the popupView engine never loads anything.

Is there a way to obtain the destination of the window.open function inside of the Callback interface or to catch whatever error is preventing the popup from being passed the destination?

Thanks!

3
  • This is indeed annoying; never encountered it, but an idea is: (1) create the new Stage in the hidden state (2) add a listener to the WebEngine.location property (3) in the listener you can actually get the URL and decide what to do, i.e. show the popup, or destroy the popup and run Lync. Commented Mar 11, 2015 at 9:51
  • Thanks for the suggestion. I added a listener to popupView's location property within the Callback function. However, the listener never triggers. It seems as if popup handler only passes the destination of the window.open function to the WebEngine returned by the Callback if the URL some form of validity check. I wonder if there is some way to intercept the window.open function before the Callback function is called. Commented Mar 11, 2015 at 19:57
  • Ha, interesting! And (as always :) jewelsea to the rescue! Commented Mar 12, 2015 at 7:59

1 Answer 1

2

Create your own protocol handler for the conf: protocol, then there will be no exception generated and you should be able to intercept and respond appropriately to the request.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.