Vaadin 7中的弹出式打印窗口与表

时间:2013-09-10 05:47:06

标签: vaadin popupwindow

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

  

表aaa = new Table();

目前,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类。

3 个答案:

答案 0 :(得分:4)

Window window = new Window("my test table popup");
window.setContent(table); 
window.setModal(true);
getUI().addWindow(window);

答案 1 :(得分:1)

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

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

在弹出窗口中:

    Table t = (Table) VaadinSession.getCurrent().getAttribute("table");

答案 2 :(得分:0)

您还可以在Table课程中初始化PrintUI。如果您需要初始化特定的Table个实例,则可以通过.getParameter("idTable")将您的表ID参数传递给用户界面(最后,它可以作为添加{ {1}}网址的参数),然后通过GET的请求参数在PrintUI的{​​{1}}方法中检索它。

相关问题