append lines to text area

I want to show the output of a background process in a Vaadin window.
The background process can be rather slow.
Lines from the output should be rendered when they appear on stdout of the background process.
It’s a bit like the Jenkins console doing a “tail -f” in the browser.

Should I use a TextArea? I haven’t found a way to append lines, though.

Thanks!
-Max

You need to append to the value of the TextArea and then call setValue(…). This means that the whole contents of the TextArea will be sent to the client on every update, which can be inefficient if the content is large and updated frequently.

The same would happen with a Label, but a Label would probably be a better choice anyway if the data is read-only.

There is an old Console add-on for Vaadin 6 but it is not ported for Vaadin 7 and would need a complete rewrite rather than a simple port.

All this said, it should be a matter of some tens of lines of code to implement a custom widget that has an efficient append() that send as an RPC call from the server - you could start with looking at the client side classes LabelConnector and VLabel (which could be further simplified considerably for this) and the
mini-tutorials
on client side development. You could use RPC to send the content to append. The only tricky bit as I see it would be to send the full content on page reload if you want that, then you might need to either override beforeClientResponse on the server side and check the “initial” flag or to explicitly request send a request from the client to get the initial content when first rendered.

You could even publish this as an add-on in the
Directory
.