Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
In-depth explanation of how Vaadin works
Let's say I have this code:
package com;
import com.vaadin.annotations.*;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.*;
@Theme("valo")
@Title("My UI")
public class MyFirstVaadinApplication extends UI
{
private int buttonNumber = 0;
@Override
public void init(VaadinRequest request)
{
VerticalLayout layout = new VerticalLayout();
setContent(layout);
layout.addComponent(new Label("Hello, Bogdansky!"));
// Have a clickable button
layout.addComponent(new Button("Push Me!",
new Button.ClickListener() {
public void buttonClick(Button.ClickEvent e) {
Notification.show("Pushed!");
}
}));
layout.addComponent(createButton(layout));
}
protected Button createButton(final VerticalLayout layout)
{
return new Button(String.format("Button %d", ++buttonNumber), (Button.ClickListener) clickEvent -> {
layout.addComponent(createButton(layout));
});
}
}
What exactly happens when I click on Button 1? I watched the net traffic and it seems to execute a server call. I attached two screenshots of the request that was sent upon clicking Button 1. The page seems to be sending some state of the client UI to the server requrest handler. I assume that some synchronization process happens on the server, where the state is restored in an instance of the MyFirstVaadinApplication class. Another interesting thing is that buttonNumber is incremented with each button click as if the same MyFirstVaadinApplication instance is used. Does the server keep around an instance of MyFirstVaadinApplication for each individual request (via a token), i.e. if I open a new tab, go to the page, the page gets a new token and a new instance of MyFirstVaadinApplication is associated with that token on the server side, and from that point on this instance is used to handle all the client requests from this particular page?
Could you please point me to an article that explains in-depth how Vaadin works exactly? It would be nice to see a sequence diagram as well.
Thank you
I guess you should start by checking out Book of Vaadin. At least chapter Architecture should be interesting.