You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

advanced-debug.asciidoc 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. ---
  2. title: Debug Mode and Window
  3. order: 3
  4. layout: page
  5. ---
  6. [[advanced.debug]]
  7. = Debug Mode and Window
  8. Vaadin applications can be run in two modes: __debug mode__ and __production
  9. mode__. The debug mode, which is on by default, enables a number of built-in
  10. debug features for Vaadin developers:
  11. * Debug Window
  12. * Display debug information in the Debug Window and server console
  13. * On-the-fly compilation of Sass themes
  14. * Timings of server calls for Vaadin TestBench
  15. It is recommended to always deploy production applications in production mode
  16. for security reasons.
  17. [[advanced.debug.mode]]
  18. == Enabling the Debug Mode
  19. The debug mode is enabled and production mode disabled by default in the UI
  20. templates created with the Eclipse plugin or the Maven archetypes. Some
  21. archetypes have a separate module and profile for producing a production mode
  22. application. The debug mode can be enabled by giving a
  23. [parameter]#productionMode=false# parameter to the Vaadin servlet
  24. configuration:
  25. [subs="normal"]
  26. ----
  27. @VaadinServletConfiguration(
  28. productionMode = **false**,
  29. ui = **MyprojectUI.class**)
  30. ----
  31. Or with a context parameter in the [filename]#web.xml# deployment descriptor:
  32. [subs="normal"]
  33. ----
  34. <context-param>
  35. <description>Vaadin production mode</description>
  36. <param-name>productionMode</param-name>
  37. <param-value>**false**</param-value>
  38. </context-param>
  39. ----
  40. Enabling the production mode disables the debug features, thereby preventing
  41. users from easily inspecting the inner workings of the application from the
  42. browser.
  43. [[advanced.debug.open]]
  44. == Opening the Debug Window
  45. Running an application in the debug mode enables the client-side Debug Window in
  46. the browser. You can open the Debug Window by adding " ?debug" parameter to the
  47. URL of the UI, for example, http://localhost:8080/myapp/?debug. The Debug Window
  48. has buttons for controlling the debugging features and a scrollable log of debug
  49. messages.
  50. [[]]
  51. .Debug Window
  52. image::img/debug-window-annotated-hi.png[]
  53. The functionalities are described in detail in the subsequent sections. You can
  54. move the window by dragging it from the title bar and resize it from the
  55. corners. The [guibutton]#Minimize# button minimizes the debug window in the
  56. corner of the browser window, and the [guibutton]#Close# button closes it.
  57. If you use the Firebug plugin for Firefox or the Developer Tools console in
  58. Chrome, the log messages will also be printed to the inspector console. In such a
  59. case, you may want to enable client-side debugging without showing the Debug
  60. Window with " ?debug=quiet" in the URL. In the quiet debug mode, log messages
  61. will only be printed to the console of the browser debugger.
  62. [[advanced.debug.log]]
  63. == Debug Message Log
  64. The debug message log displays client-side debug messages, with time counter in
  65. milliseconds. The control buttons allow you to clear the log, reset the timer,
  66. and lock scrolling.
  67. [[]]
  68. .Debug Message Log
  69. image::img/debug-log-hi.png[]
  70. [[advanced.debug.log.custom]]
  71. === Logging to Debug Window
  72. You can take advantage of the debug mode when developing client-side components,
  73. by using the standard Java [classname]#Logger# to write messages to the log. The
  74. messages will be written to the debug window and Firebug console. No messages
  75. are written if the debug window is not open or if the application is running in
  76. production mode.
  77. [[advanced.debug.info]]
  78. == General Information
  79. The [guilabel]#General information about the application(s)# tab displays
  80. various information about the UI, such as version numbers of the client and
  81. servlet engine, and the theme. If they do not match, you may need to compile the
  82. widget set or theme.
  83. [[]]
  84. .General Information
  85. image::img/debug-info.png[]
  86. [[advanced.debug.hierarchy]]
  87. == Inspecting Component Hierarchy
  88. The [guilabel]#Component Hierarchy# tab has several sub-modes that allow
  89. debugging the component tree in various ways.
  90. [[advanced.debug.hierarchy.tree]]
  91. === Connector Hierarchy Tree
  92. The [guibutton]#Show the connector hierarchy tree# button displays the
  93. client-side connector hierarchy. As explained in
  94. <<../gwt/gwt-overview.asciidoc#gwt.overview,"Integrating
  95. with the Server-Side">>, client-side widgets are managed by connectors that
  96. handle communication with the server-side component counterparts. The connector
  97. hierarchy therefore corresponds with the server-side component tree, but the
  98. client-side widget tree and HTML DOM tree have more complexity.
  99. [[]]
  100. .Connector Hierarchy Tree
  101. image::img/debug-hierarchy-tree.png[]
  102. Clicking on a connector highlights the widget in the UI.
  103. [[advanced.debug.hierarchy.inspect]]
  104. === Inspecting a Component
  105. The [guibutton]#Select a component in the page to inspect it# button lets you
  106. select a component in the UI by clicking it and display its client-side
  107. properties.
  108. To view the HTML structure and CSS styles in more detail, you can use Inspector in
  109. Firefox or the Developer Tools in Chrome.
  110. [[advanced.debug.hierarchy.analyze]]
  111. === Analyzing Layout Problems
  112. The [guilabel]#Check layouts for potential problems# button analyzes the
  113. currently visible UI and makes a report of possible layout related problems. All
  114. detected layout problems are displayed in the log and also printed to the
  115. console.
  116. [[figure.advanced.debug.hierarchy.analyze]]
  117. .Debug window showing the result of layout analysis.
  118. image::img/debug-window-analyze-layouts.png[]
  119. Clicking on a reported problem highlights the component with the problem in the
  120. UI.
  121. The most common layout problem is caused by placing a component that has a
  122. relative size inside a container (layout) that has undefined size in the
  123. particular direction (height or width). For example, adding a
  124. [classname]#Button# with 100% width inside a [classname]#VerticalLayout# with
  125. undefined width. In such a case, the error would look as shown in
  126. <<figure.advanced.debug.hierarchy.analyze>>.
  127. [classname]#CustomLayout# components can not be analyzed in the same way as
  128. other layouts. For custom layouts, the button analyzes all contained
  129. relative-sized components and checks if any relative dimension is calculated to
  130. zero so that the component will be invisible. The error log will display a
  131. warning for each of these invisible components. It would not be meaningful to
  132. emphasize the component itself as it is not visible, so when you select such an
  133. error, the parent layout of the component is emphasized if possible.
  134. [[advanced.debug.hierarchy.used]]
  135. === Displaying Used Connectors
  136. The last button, [guibutton]#Show used connectors and how to optimize widget
  137. set#, displays a list of all currently visible connectors. It also generates a
  138. connector bundle loader factory, which you can use to optimize the widget set so
  139. that it only contains the widgets actually used in the UI. Note, however, that
  140. it only lists the connectors visible in the current UI state, and you usually
  141. have more connectors than that.
  142. [[advanced.debug.communication]]
  143. == Communication Log
  144. The [guilabel]#Communication# tab displays all server requests. You can unfold
  145. the requests to view details, such as the connectors involved. Clicking on a
  146. connector highlights the corresponding element in the UI.
  147. You can use Firebug or Developer Tools in Firefox or Chrome, respectively, to
  148. get more detailed information about the requests and responses.
  149. [[advanced.debug.devmodes]]
  150. == Debug Modes
  151. The [guilabel]#Menu# tab in the window opens a sub-menu to select various
  152. settings. Here you can also launch the GWT SuperDevMode, as described in
  153. <<../clientside/clientside-debugging#clientside.debugging,"Debugging
  154. Client-Side Code">>.