Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Vaadin Page Source

kadireray doganlar
8 years ago Mar 24, 2015 11:46am
Marko Grönroos
8 years ago Mar 24, 2015 1:36pm
// Panel to display HTML of dumped content
final Panel panel = new Panel("Dumped Content");
panel.setWidth("640px");
panel.setHeight("400px");
final Label dumpContent = new Label();
panel.setContent(dumpContent);
layout.addComponent(panel);

// Handle dump content from server-side
Page.getCurrent().getJavaScript().addFunction("dumpcontent",
    new JavaScriptFunction() {
        @Override
        public void call(JSONArray arguments)
             throws JSONException {
            // Display the dumped HTML as text
            dumpContent.setValue(arguments.getString(0));
    }
});

// Button for dumping the content
Button takeadump = new Button("Take a Dump");
takeadump.addClickListener(new ClickListener() {
    @Override
    public void buttonClick(ClickEvent event) {
        Page.getCurrent().getJavaScript().execute(
"dumpcontent(document.documentElement.innerHTML)");
    }
});
layout.addComponent(takeadump);
Michael Hentze
6 years ago Mar 06, 2017 10:37am