You are what you deploy to Production Environment and this is also true if you are doing Vaadin Application Development. Here are some points that I’ve extracted from my experience.
Vaadin Application Development
Vaadin uses Live Reloading and not Hot Reload. In IntelliJ rebuilding is done with Ctrl + F9. After changes the application are reloaded without keeping internal state that is the beast feature of other frameworks like Flutter. The way to have state in some sense – in Vaadin and in Web Applications in General – is the URL and the page, request parameters, query string hash.
And to add URL paramters, navigation url needs to add them accordingly like this:
or via the API
There is a solution – even if you have Components created inline and you need to add them to the tree and change the routing. https://vaadin.com/docs/latest/routing/updating-url-parameters
- Expanded Text in a Layout
Common use cases it to expand a text inside a Horizontal or VerticalLayout and add some additional component. You will find that using the Text class will not work. You will need to use the Span class. This comes from the Web – Block or Inline Tags. Whatever amount abstractions you put, you cannot escape from the limitations of the platform that the application runs on.
- https://vaadin.com/docs/latest/components/message-input – Common widget to collect single string value.
- https://vaadin.com/docs/latest/components/confirm-dialog – Common Component to collect confirmation from the user. It is a must for delete operations.
Common requirement for apps the feature to Upload Files: https://vaadin.com/docs/latest/components/upload. My reccomendation is to use the File Buffer options. You don’t know what files your users will pick up that will overflow the Server’s memory.
There are two options to download File in Vaadin Application.
- Use standard anchor thag with hrefs /Link/ – pointing to files on the server. These are accessible outside of the Vaadin Session.
- Use FileDownloader with StreamResource Link https://vaadin.com/docs/v8/framework/articles/LettingTheUserDownloadAFile. These are only accessible from within a Vaadin App.
Changes in Vaadin Code in the Migration to Production
Vaadin Interprets Front-End Code. To get the code ready for production you need to build it https://vaadin.com/docs/latest/production/production-build. I’ve personally used this:
mvn clean package -Pproduction -Dvaadin.force.production.build=true
The application may also need these settings in application.properties:
If your app needs the user’s IP – in production – your app will most likely run behind load balancer. You need to change the IP origin: https://stackoverflow.com/questions/61249589/need-to-get-the-actual-ip-address-in-vaadin-8-8-5.
- VaadinRequest.getCurrent().getRemoteAddr() – if the java app is visible
VaadinRequest.getCurrent().getHeader("X-Forwarded-For")– if the app is behind load balancer