Want a little more understanding on Vaadin

Vaadin is pretty good to develop web apps as my short-term trial, I think. Still in learning process, here I am trying to gain a little more understanding on Vaadin framework. Vaadin changes the methodogy of web-based development and makes it more like a kind of server-side or traditional client development rather than HTML/Servlet.

Here are my few questions to the framework regarding server-client communication within Vaadin. For example I created a button in the app, when user clicks the button the code would be executed something like below (just presenting it as pseudocode)

public void buttonClick(ClickEvent event)
{
[1]
MyData theContent = getDataFromDB();
[2]
changeUIContent(theContent); // e.g. change label content, purely UI change
[3]
updateDataToDB(); // to save a updated content
[4]
showWindow(“Operation is done now.”); // to tell the work done to show a message or pop-up window
}

for this example code above, how many times Vaadin will trigger server-client talks over AJAX/HTTP? Or Vaadin is “smart” to just trigger the talk once to have better efficiency?

If the code changed below, is it same answer to the question?
public void buttonClick(ClickEvent event)
{
[1]
MyData theContent = getDataFromDB();
[2]
updateDataToDB(); // to save a updated content
[3]
showWindow(“Operation is done now.”); // to tell the work done to show a message or pop-up window
}
Are the first two code lines executed in a single AJAX/HTTP request? Or the truth is: no matter what the code is in the buttonClick function,Vaadin framework just sends a single AJAX request to server then refresh UI, if so wondering how Vaadin handles the logic/state, e.g. some code to be executed in server while some to be executed in client side and they would run in certain time-sequence (logic).

Any relevant resource/posts I can learn to get this educated more?

Thanks.

In Vaadin when an event happen on client side (button click, …) the corresponding listener will be called on the serve side.
As long as the listener does not return, no more request are made which means that in both case, only one round trip will be done.

During that time, the client side waits for the server to return something.

This kind of blocking flow is really easy to understand, follow and debug.

For more details, you can check the book of vaadin chapters on UIDL (the language used internally by Vaadin to describe UI changes)
here
and
here

Due to this blocking flow architecture, background updates are a bit tricky (but not too much), there is a good post on how to make it work as well as a good explanation of vaadin flow
here

You can also run vaadin and add a “?debug” parameter to the URL, it will display a debug window with the raw messages exchanged by client and server.
See for instance
http://demo.vaadin.com/sampler?debug
(note that this feature can be disabled easily on production server)

Thanks for the good replies.