setImmediate(what now?)

Everything must be working too well, and it’s spring, so it’s time for a little housekeeping. My app pre-dates Vaadin 7.2 and ticket
so I used “setImmediate(true)” here and there following the examples, and have added them as part of troubleshooting efforts during the development process. Now there are 163 setImmediate(true)'s living in the app, many of which must be redundant now.

A smarter person would probably leave well enough alone, but I’d like to put these things where needed and take them away where they’re not. What is a sensible strategy? Comment them all out and look for trouble, then uncomment as needed? Ideally I’d understand which are needed and simply remove those that aren’t. But I’ve lost track of when they are needed and when not.

Any pointers?

Currently Vaadin 7.4.5, Tomcat 8.0.22, Java 8u45

Quick recap of what set immediate does. The immediate mode defines if events from a component on the client side should be immediately sent to the server or if they should be put in a queue. The queue is sent to the server the next time there is an HTTP request going to the server (except heartbeats).

In practice, what this used to mean, was that when you hade a component such as the TextField and you applied a ValueChangeListener to it, the ValueChangeListener didn’t get triggered immediately on the server. Once you set the TextField to immediate, then the listener got triggered once the value changed.

The default immediate value was not change to true, but rather, the logic was changes so that if you apply any listeners to a component, then they will implicitly be marked as immediate, thus removing the need to explicitly mark a component as immediate.

TL;DR - For most cases, it should be safe to remove the setImmediate call. If you have a listener applied to the component, then it will be immediate anyway. Haven’t tried, but you still might need to use setImmediate if you want some instant validation for fields.

Exactly as Kim said. Instant validation is the only place where I have needed setImmediate(true) calls recently. And even there I have only needed it in my
Viritin add-on
that puts your instant validation to next level (not just after you leave the field but also while you type).