Immediate - When would it be set to false

Just went through the book of Vaadin. In 100% of the setImmediate statements in the book, you set it to true. In what situation would you want immediate not set to true?

We use setImmediate(false) on most Forms in which we don’t make any updates until a Save button is clicked. Of course, if the field has validators or needs an immediate response, you still go immediate, but most fields on a Form would not need it.

Immediate has the cost of as soon as the field changes value, it is sent to the server. When you need it, it’s terrific, but when you don’t, the Form/view will be more responsive if it’s not set.

Thanks. I was thinking in terms of the API, this might be a candidate for simplification. I’m doing an awful lot of setImmediate(true), when maybe it should be a different named setting available in a much more limited context.

FWIW, I agree with this : I can count the number of times I’ve wanted setImmediate(false) on the fingers of one foot.

Well, you will generally only see setImmediate(true) calls because the default is false, so you don’t need to call setImmediate(false) unless you are toggling it back from being true.

I believe Form.setImmediate(true) will set all of its Fields to true as well, so if your fields are in a Form, you perhaps can use this one call to replace setting it on each field.

There’s a ticket for changing the default from false to true (http://dev.vaadin.com/ticket/8029). Seems like such a change is only good if they give a simple method to set the default value to use for immediate so at the very least those who want the default to remain false (to match their current code) can call that to keep the current behavior.

The value false of the immediate flag has never guaranteed that changes would not be sent immediately, it is just a hint that they do not need to be sent immediately. Thus, using the value true as the default should not break anything but should simplify many applications and make things easier as there is one concept less to care about.

In most applications, using immediate fields everywhere should not even affect performance much as the requests are sent asynchronously, and might actually improve responsiveness of the final commit action which is when what the user sees is typically fully dependent on the response from the server. In Vaadin 7, RPC requests made in the same JavaScript execution “block” are coalesced, so there aren’t that many extraneous HTTP requests. Using a push channel (websockets) in Vaadin 7.1 can reduce the overhead even further.

In the current release is there away to set the default true?

No easy way that I can think of without hacking AbstractComponent/AbstractComponentState or using own subclasses for all components.

Note, though, that in the upcoming Vaadin 7.2 all fields that have a ValueChangeListener and for which immediate more hasn’t explicitly been turned off will effectively behave as if they were immediate. This should significantly reduce the number of cases where you need to call setImmediate(true).

The issue I am seeing is if the immediate is not set true, then the property that is attached to the field is not updated, when the field is updated. When I set it to true then the property is updated when I leave the field. If the change that is being made resolves that then that is great.