/vaadin-dynamic-theme-demo

A demo for dynamically changing the theming of a Vaadin application

Primary LanguageJavaThe UnlicenseUnlicense

Dynamic Theme Demo

This project showcases dynamic theming in Vaadin Flow.

The ThemeUtil and ThemeSelector classes allow dynamically changing the theme, by setting an attribute on the body element. The styles in /frontend/themes/dynamicthemedemo depend on this attribute.

The ThemeBoostrapListener is used to set the initial attribute on page load.

Running and debugging the application

Running the application from the command line.

To run from the command line, use mvn and open http://localhost:8080 in your browser.

Running and debugging the application in Intellij IDEA

  • Locate the Application.java class in the Project view. It is in the src folder, under the main package's root.
  • Right-click on the Application class
  • Select "Debug 'Application.main()'" from the list

After the application has started, you can view it at http://localhost:8080/ in your browser. You can now also attach breakpoints in code for debugging purposes, by clicking next to a line number in any source file.

Running and debugging the application in Eclipse

  • Locate the Application.java class in the Package Explorer. It is in src/main/java, under the main package.
  • Right-click on the file and select Debug As --> Java Application.

Do not worry if the debugger breaks at a SilentExitException. This is a Spring Boot feature and happens on every startup.

After the application has started, you can view it at http://localhost:8080/ in your browser. You can now also attach breakpoints in code for debugging purposes, by clicking next to a line number in any source file.

Project structure

  • MainView.java in src/main/java contains the navigation setup. It uses App Layout.
  • views package in src/main/java contains the server-side Java views of your application.
  • views folder in frontend/ contains the client-side JavaScript views of your application.

What next?

vaadin.com has lots of material to help you get you started: