Changing Flow behavior with runtime configuration.

Flow application have extra parameters that may be set to change its behavior.

How to set parameters

Parameters can be set the following way:

  • by setting the system property

In this case, vaadin. prefix is needed to be specified before the parameter names. For instance, Spring Boot can be configured in application.properties file. For more details, refer to Flow Spring configuration

Alternatively, system properties can be set via command line:

bash

  1. mvn jetty:run -Dvaadin.frontend.url.es6=http://mydomain.com/es6/ -Dvaadin.frontend.url.es5=http://mydomain.com/es5/
  • by setting the servlet init parameters

You can use the traditional web.xml file or the Servlet 3.0 @WebServlet annotation:

Java

  1. @WebServlet(urlPatterns = "/*", name = "myservlet", asyncSupported = true, initParams = {
  2. @WebInitParam(name = "frontend.url.es6", value = "http://mydomain.com/es6/"),
  3. @WebInitParam(name = "frontend.url.es5", value = "http://mydomain.com/es5/") })
  4. @VaadinServletConfiguration(productionMode = false)
  5. public class MyServlet extends VaadinServlet {
  6. }

Or when using the web.xml file:

XML

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <web-app
  3. id="WebApp_ID" version="3.0"
  4. xmlns="http://java.sun.com/xml/ns/j2ee"
  5. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  6. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
  7. http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
  8. <servlet>
  9. <servlet-name>myservlet</servlet-name>
  10. <servlet-class>
  11. com.vaadin.server.VaadinServlet
  12. </servlet-class>
  13. <init-param>
  14. <param-name>frontend.url.es6</param-name>
  15. <param-value>http://mydomain.com/es6/</param-value>
  16. </init-param>
  17. <init-param>
  18. <param-name>frontend.url.es5</param-name>
  19. <param-value>http://mydomain.com/es5/</param-value>
  20. </init-param>
  21. </servlet>
  22. <servlet-mapping>
  23. <servlet-name>myservlet</servlet-name>
  24. <url-pattern>/*</url-pattern>
  25. </servlet-mapping>
  26. </web-app>
Note
System properties override application properties ergo if you have both properties with the same name specified, the system one will be used.

Parameters and description

  • disable.webjars - if set to true, webjars would be ignored during request resolving, allowing Flow to use external source of web components’ files.

    Note
    Webjars are enabled for development mode and disabled for production mode by default, unless explicitly overridden by parameter specified. In the future, webjars are expected to the always enabled by default.

Next group of parameters are paths to external web component’s locations in development and production modes.

Development mode:

  • frontend.url.dev (default value is context://frontend) – a location Flow searches web components’ files in development mode. Supports changes reload on a working application and should be set as a directory, containing bower.json file.

Production mode:

  • productionMode (default value is false) – turns application to work in production mode

  • frontend.url.es5 (default value is context://frontend-es5) - a location Flow searches web components’ files in production mode when the request is coming from older browsers, not supporting es6, default web components’ development language version.

  • frontend.url.es6 (default value is context://frontend-es6) - a location Flow searches web components’ files in production mode for requests from modern browsers

  • load.es5.adapters (default value is true) – include polyfills for browsers that does not support ES6 to their initial page. In order for web components to work, extra libraries (polyfills) are required to be loaded, can be turned off if different versions or libraries should be included instead.