Vaadin:使用来自按钮的绝对 url 路径打开新窗口 [英] Vaadin: open new window with ABSOLUTE url path from a BUTTON

查看:26
本文介绍了Vaadin:使用来自按钮的绝对 url 路径打开新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张地址表.我有一个按钮,你可以点击它,我想在单独的窗口中打开谷歌搜索地址.我已经用 BrowserWindowOpener.

I have a table with addresses. I have a button you can click which I want to open a google search for the address in a separate window. I have tried this code with BrowserWindowOpener.

getUI().getPage().open(url, "_blank")

BrowserWindowOpener opener = new BrowserWindowOpener(url);
opener.extend(googleBtn)

但两者都将我的网址附加到当前路径.我只想在单独的窗口中在 google 中运行搜索.我相信这比我做的要简单得多.至少应该是这样.谢谢.

but both are appending my url to the current path. I want to simply run a search in google in a separate window. I'm sure this is much simpler than I'm making it. It sure should be, at least. Thanks.

推荐答案

Brimby,您的第二次尝试是对的.BrowserWindowOpener 扩展是要走的路.您应该使用 ExternalResource 具有如下绝对 URL 的实例:

Brimby, you were right with your second try. The BrowserWindowOpener extension is the way to go. You should use an ExternalResource instance with an absolute URL like this:

public class OpenGoogleUI extends UI {
    @Override
    protected void init(VaadinRequest request) {
        BrowserWindowOpener extension = new BrowserWindowOpener(new ExternalResource("https://www.google.by/#q=vaadin"));
        Button button = new Button("Open Google");
        extension.extend(button);
        setContent(button);
    }
}

这篇关于Vaadin:使用来自按钮的绝对 url 路径打开新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆