Create screenshot of browser content?

Hi there,

we have a Swing application running lots of times in production. Whenever an exception occurs, we automatically store the current exception stack trace, a log file and a screenshot of the current user´s session into the database, along with some information about the current user, his workstation and so on. This enables us to very quickly identify problems in pruduction environment and often fix them even before the users have told us about it.

In priciple, this mechanism also works with Vaadin - except for the screenshot.

But as Vaadin simulates the user´s gui session on the server, I´m now wondering if it could be possible grab to that information also and use it to render the browser content on a different machine later, even after a restart of the tomcat server. So I´m looking for a way to persistently serialize and deserialize the current user´s session.

I´m currently using Vaadin 7beta11, Tomcat 6.

Any ideas?

Thanks,
Stefan

There are at least tree different addons in the directory, that allow taking a screenshot of the browser. Although none of those already supports Vaadin 7, it should be fairly simple to either port them yourself or create a new Widget following one of their paths… By the way, at least I would be interested in the whole mechanism too. So if you could create an addon, that provides error-details on each thrown exception, this would be great.

The addons I have found are


ScreenDump


Screenshot


JS Screenshot

Tobias,

besides the fact that I´m fairly new to Vaadin and therefore do not really feel able to port those add ons to Vaadin 7 - they seem to follow the approach to create an invisible client side component with some functionality to grab the current browser´s html. Could the extension mechanism that Vaadin 7 offers (
example from wiki
) be an alternative (better?) solution?

Stefan

Yes, these should be extensions in Vaadin 7.

Although I haven’t looked at their code, the last one (
JS Screenshot
) might even be very easy to adapt with the Vaadin 7 JavaScript extension support without requiring client side coding if you find a good way to transfer the resulting screenshot.

I haven’t yet ported the ScreenDump to Vaadin 7, and don’t have time to do all the packaging right now, but it is trivial to do with JavaScript call and a JavaScript function call to the server-side. I just added
this example
that does exactly that.

// 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);

Much much easier than with Vaadin 6, which was also quite simple, but without needing a widget.

Note that the dump is missing the root “html” element, as it’s its inner HTML. Also note that you can’t display the HTML in a browser without removing the code that loads the client-side engine (widget set).

Wow, so easy!!!

Thanks a lot, this works perfectly.

Stefan