0

我是 Vaadin 的新手。如何将表格组件传递到 Vaadin 7 中的新弹出屏幕?假设我已经使用 com.vaadin.ui.Table 创建了表。

表 aaa = 新表();

目前 Vaadin 教程只展示了如何在不传递组件/数据的情况下创建打印弹出窗口。基于以下代码

public static class PrintUI extends UI {
    @Override
        protected void init(VaadinRequest request) {
        // Have some content to print
        setContent(new Label(
            "<h1>Here's some dynamic content</h1>\n" +
            "<p>This is to be printed.</p>",
            ContentMode.HTML));

        // Print automatically when the window opens
        JavaScript.getCurrent().execute(
            "setTimeout(function() {" +
            "  print(); self.close();}, 0);");
    }
}
...

// Create an opener extension
BrowserWindowOpener opener =
        new BrowserWindowOpener(PrintUI.class);
opener.setFeatures("height=200,width=400,resizable");

// A button to open the printer-friendly page.
Button print = new Button("Click to Print");
opener.extend(print);

如果有人能告诉我如何将 Table aaa 传递给 PrintUI 类,我将不胜感激。

4

3 回答 3

4
Window window = new Window("my test table popup");
window.setContent(table); 
window.setModal(true);
getUI().addWindow(window);
于 2014-06-17T10:10:37.267 回答
1

我发现在弹出窗口中将对象传递给 UI 类的唯一方法是将它们存储在会话中:

    Table table = new Table();
    VaadinSession.getCurrent().setAttribute("table", table);

在弹出窗口中:

    Table t = (Table) VaadinSession.getCurrent().getAttribute("table");
于 2013-11-01T14:24:43.483 回答
0

您还可以Table在您的PrintUI班级中初始化您的。如果你需要初始化一个特定的Table实例,你可以通过,比如说,你的 table id 参数传递给 UI .getParameter("idTable")(最后,它作为向GETURL 添加一个参数),然后在你PrintUIinit()方法中检索它 via请求参数与.getParameter("idTable").

于 2018-01-18T17:18:43.313 回答