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:

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:

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

Or when using the web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<web-app
  id="WebApp_ID" version="3.0"
  xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
      http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

  <servlet>
    <servlet-name>myservlet</servlet-name>
    <servlet-class>
        com.vaadin.server.VaadinServlet
    </servlet-class>

    <init-param>
      <param-name>frontend.url.es6</param-name>
      <param-value>http://mydomain.com/es6/</param-value>
    </init-param>

    <init-param>
      <param-name>frontend.url.es5</param-name>
      <param-value>http://mydomain.com/es5/</param-value>
    </init-param>
  </servlet>

  <servlet-mapping>
    <servlet-name>myservlet</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>
</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.