Vaadin applications can be run in two modes: debug mode and production mode. The debug mode, which is on by default, enables a number of built-in debug features for the developers. The features include:

  • Debug Window for accessing debug functionalities
  • Display debug information in the Debug Window and server console.
  • Analyze layouting button that analyzes the layout for possible problems.

All applications are run in the debug mode by default (since IT Mill Toolkit version 5.3.0). The production mode can be enabled, and debug mode thereby disabled, by adding a productionMode=true parameter to the servlet context in the web.xml deployment descriptor:

<context-param>
  <description>Vaadin production mode</description>
  <param-name>productionMode</param-name>
  <param-value>true</param-value>
</context-param>

Enabling the production mode disables the debug features, thereby preventing users from easily inspecting the inner workings of the application from the browser.

The Analyze layouts button analyzes the currently visible layouts and makes a report of possible layout related problems. All detected layout problems are displayed in the log and also printed to the console.

The most common layout problem is caused by placing a component that has a relative size inside a container (layout) that has undefined size, for example, adding a 100% wide Panel inside a HorizontalLayout with no width specification. In such a case, the error will look as shown below:

Vaadin DEBUG
- Window/1a8bd74 "My window" (width: MAIN WINDOW)
  - HorizontalLayout/1cf243b (width: UNDEFINED)
    - Panel/12e43f1 "My panel" (width: RELATIVE, 100.0 %)
Layout problem detected: Component with relative width inside a HorizontalLayout with no width defined
Relative sizes were replaced by undefined sizes, components may not render as expected.
			

This particular error tells that the Panel "My panel" is 100% wide while the width of the containing HorizontalLayout is undefined. The components will be rendered as if the the width of the contained Panel was undefined, which might not be what the developer wanted. There are two possible fixes for this case: if the Panel should fill the main window horizontally, set a width for the HorizontalLayout (for example 100% wide), or set the width of the Panel to "undefined" to render the it as it is currently rendered but avoiding the warning message.

The same error is shown in the Debug Window in a slightly different form and with an additional feature (see Figure 12.7, “Debug Window Showing the Result of Analyze layouts.”). Checking the Emphasize component in UI box will turn red the background of the component that caused a warning, making it easy for the developer to figure out which component each warning relates to. The messages will also be displayed hierarchically, as a warning from a containing component often causes more warnings from its child components. A good rule of thumb is to work on the upper-level problems first and only after that worry about the warnings from the children.