Skip to content

feat: support DynamicTheme initialization in multi-version add-ons#143

Merged
paodb merged 1 commit intomasterfrom
feat-multi-version-dynamic-theme
Feb 4, 2026
Merged

feat: support DynamicTheme initialization in multi-version add-ons#143
paodb merged 1 commit intomasterfrom
feat-multi-version-dynamic-theme

Conversation

@javier-godoy
Copy link
Member

@javier-godoy javier-godoy commented Feb 4, 2026

Close #142

Summary by CodeRabbit

Release Notes

  • New Features

    • Dynamic theme initialization support added for Vaadin versions 14-25 and 23-25, enabling users to configure and automatically apply themes to their applications with automatic CSS stylesheet injection.
  • Documentation

    • Documentation expanded with comprehensive setup instructions, configuration guidance, and workaround details for implementing dynamic themes on supported versions.

@coderabbitai
Copy link

coderabbitai bot commented Feb 4, 2026

Walkthrough

Extended DynamicTheme feature support to Vaadin versions that cannot use AppShellConfigurator by introducing an alternative initialization path via IndexHtmlResponse and a service initializer that loads theme configuration from a properties file. Updated documentation and service loader registration accordingly.

Changes

Cohort / File(s) Summary
Documentation
README.md
Added guidance for Vaadin 14-25 targets on limitations with AppShellConfigurator approach and documented workaround using META-INF/dynamic-theme.properties configuration file.
Core Initialization
src/main/java/com/flowingcode/vaadin/addons/demo/DynamicTheme.java
Added new public method initialize(IndexHtmlResponse response) to enable theme initialization via HTML response injection, complementing the existing AppShellSettings path.
Service Initialization
src/main/java/com/flowingcode/vaadin/addons/demo/DynamicThemeInitializer.java
New service initializer class that loads theme configuration from properties resource and registers an IndexHtmlRequestListener to initialize themes for all requests.
Service Registration
src/main/resources/META-INF/services/com.vaadin.flow.server.VaadinServiceInitListener
Updated service loader registration to include DynamicThemeInitializer.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • mlopezFC
  • paodb
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main objective: adding DynamicTheme initialization support for multi-version add-ons, which is the primary purpose of the PR.
Linked Issues check ✅ Passed The PR implements all requirements from issue #142: enables DynamicTheme initialization across Vaadin 14/23/24-25 without requiring AppShellConfigurator by introducing an IndexHtmlRequestListener-based approach via DynamicThemeInitializer.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objective: the new DynamicThemeInitializer class, IndexHtmlResponse initialization method, service loader registration, and README guidance are all necessary for solving the multi-version DynamicTheme initialization problem.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-multi-version-dynamic-theme

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@README.md`:
- Around line 67-71: The fenced code block in README.md showing the
dynamic-theme.properties content lacks a language tag, triggering MD040; update
the block that currently contains "theme=LUMO" to use a properties language tag
(i.e., change the opening fence to ```properties) so the snippet is fenced as a
properties block; locate the block in the README where the instructions mention
creating src/test/resources/META-INF/dynamic-theme.properties and add the
language tag to that fenced code block.

In
`@src/main/java/com/flowingcode/vaadin/addons/demo/DynamicThemeServiceInitListener.java`:
- Around line 1-38: The DynamicThemeServiceInitListener.serviceInit currently
calls DynamicTheme.valueOf(themeName.toUpperCase()) which will throw
IllegalArgumentException for invalid values; update serviceInit to trim the
themeName, convert to upper case using Locale.ROOT (e.g.,
themeName.trim().toUpperCase(Locale.ROOT)), and wrap the DynamicTheme.valueOf
call in a try-catch that catches IllegalArgumentException; when caught, do not
rethrow—log a warning instead and skip registering the IndexHtmlRequestListener
(add a Logger field to the class and use it to record the invalid theme value
and the exception), leaving valid values to call
event.addIndexHtmlRequestListener(theme::initialize).

@javier-godoy javier-godoy force-pushed the feat-multi-version-dynamic-theme branch from ed7f717 to 6610c4b Compare February 4, 2026 18:33
@javier-godoy javier-godoy force-pushed the feat-multi-version-dynamic-theme branch from 6610c4b to a8a3365 Compare February 4, 2026 19:17
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 4, 2026

@javier-godoy javier-godoy requested a review from paodb February 4, 2026 19:26
@javier-godoy javier-godoy marked this pull request as ready for review February 4, 2026 19:26
@paodb paodb merged commit 72213fc into master Feb 4, 2026
3 checks passed
@paodb paodb deleted the feat-multi-version-dynamic-theme branch February 4, 2026 19:41
@github-project-automation github-project-automation bot moved this to Pending release in Flowing Code Addons Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pending release

Development

Successfully merging this pull request may close these issues.

DynamicTheme support in Vaadin 25+ for multi-version add-ons

2 participants