I managed to add Thymeleaf to my project, created a Server Sent Event endpoint and made it to call the Thymeleaf template engine from code.
The client registers to that SSE endpoint using pure Javascript. When the client connects to the endpoint, the controller calls the Thymeleaf template engine which processes a specified fragment in a specified template and returns the finished HTML code as a String. That String is then sent by the controller to the client as a custom event using the registered Server Sent Event endpoint, where the Javascript message handler receives the event with the HTML and displays it for demonstration purposes as a pop up message using window.alert().
The current status of the project can be seen here:
https://gitlab.marvin-haagen.de/software/oskar/-/tree/23-migrate-to-vaadin?ref_type=heads
My next step is to extend the Javascript code on the client side so that it replaces the DOM subtree of the component addressed by the received message with the HTML specified in the message received from the SSE endpoint. I need to write that function in such a way that I can reuse it for updating other components on the webpage without having to modify the Javascript code.
Also I need to find a way to share that SSE connection between multiple browser tabs because there is a low limit to the amount of SSE connections that can be active at the same browser for the same domain.