Confirm dialog problem

I want to open up a URL page in the browser using BrowserWindowOpener but the page doest seem to open? Any Idea?

final BrowserWindowOpener browserWindowOpener = new BrowserWindowOpener(new StreamResource(getSource((Document) response.getData()), document.getTitle()));

        ConfirmDialog dialog = ConfirmDialog.show(UI.getCurrent(), "Warning", "The document you have chosen to view is" + document.getSize() + " do you wish to continue?" , "Yes", "No", new ConfirmDialog.Listener() {
                    @Override
                    public void onClose(ConfirmDialog dialog) {
                        if (!dialog.isConfirmed()) {
                            dialog.close();    
                        }
                        else {
                            browserWindowOpener.extend(dialog.getOkButton());
                         dialog.close();
                        }
                
                    }
                    
                });
                
                dialog.setIcon(new ThemeResource("icons/Warning_icon.png"));
                dialog.setWidth(297, Unit.PIXELS);
                dialog.setHeight(200, Unit.PIXELS);
                dialog.setStyleName("warning-dialog");

It looks to me like you’re adding the BrowserWindowOpener to the OkButton in the Listener which gets executed AFTER the button was clicked. This way the Extension will not fire. You should add the BrowserOpener to the Button before the button can be clicked (For example when you’re initiliazing the Dialog Window. Inside the extension you might be able to access variable with which you can determine whether to open the Browser window or not.

Another way without the extension (which might be deprecated now or not, there were some discussions about it if i remember correctly) would be to use Page.getCurrent().open(ExternalResource extres); which opens the Resource link immidately after being executed. (Some browser may block it though)

This is my function I have a link and when I click it should open up a Confirmdialog box and if pressed OK to open up a page. But when I add this the page opens but its tomcat 404 saying connector problem.

private Component buildLink(final Response response, final Document document) {

    btn = new Button("Click me");
    btn.setStyleName("link-button");
     
    final ConfirmDialog dialog = ConfirmDialog.getFactory().create("Title", "", "OK","Cancel");        

    btn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            BrowserWindowOpener browserWindowOpener = new BrowserWindowOpener(new StreamResource(getSource((Document) response.getData()), document.getTitle()));    

      
                    
                browserWindowOpener.extend(dialog.getOkButton());
                dialog.setIcon(new ThemeResource("icons/Warning_icon.png"));
                dialog.setWidth(297, Unit.PIXELS);
                dialog.setHeight(200, Unit.PIXELS);
                dialog.setStyleName("warning-dialog");
                dialog.show(UI.getCurrent(), null, false);

        }      
    
    });
        
    return btn;
}