Skip to content

Commit 28a5df9

Browse files
committed
deprecate: deprecate DynamicTheme.initialize(AppShellSettings)
1 parent ab11c94 commit 28a5df9

3 files changed

Lines changed: 7 additions & 22 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,7 @@ public class AppShellConfiguratorImpl implements AppShellConfigurator {
6767

6868
The annotation is read when the application starts, so the default theme also applies to sessions that did not load `index.html` (for example, after the server restarts while a page is open, or when `index.html` is served from a cache).
6969

70-
Alternatively, `DynamicTheme` can be initialized in the `configurePage` method of the `AppShellConfigurator`. With this approach, the default theme is only known after `index.html` has been served at least once.
71-
72-
```java
73-
public class AppShellConfiguratorImpl implements AppShellConfigurator {
74-
75-
@Override
76-
public void configurePage(AppShellSettings settings) {
77-
if (DynamicTheme.isFeatureSupported()) {
78-
DynamicTheme.LUMO.initialize(settings);
79-
}
80-
}
81-
82-
}
83-
```
70+
Initializing `DynamicTheme` from the `configurePage` method of the `AppShellConfigurator` (i.e. calling `DynamicTheme.LUMO.initialize(settings)`) is deprecated, because the default theme is only known after `index.html` has been served at least once. Replace that call by annotating the `AppShellConfigurator` with `@DefaultDynamicTheme`.
8471

8572
When targeting Vaadin 14-25 or 23-25, the `AppShellConfigurator` approach cannot be used due to framework and library limitations.
8673
To resolve this, you must create a configuration file `src/test/resources/META-INF/dynamic-theme.properties` with the following content:

‎base/src/main/java/com/flowingcode/vaadin/addons/demo/DynamicTheme.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,12 @@ public static DynamicTheme getCurrent() {
169169
* @throws UnsupportedOperationException if the runtime Vaadin version is older than 25
170170
* @throws IllegalStateException if the {@link AppShellConfigurator} is configured with the legacy
171171
* {@link Theme} annotation
172+
* @deprecated Annotate the {@link AppShellConfigurator} with {@link DefaultDynamicTheme} instead.
173+
* This method is only invoked when {@code index.html} is generated, therefore the
174+
* default theme is unknown to sessions that did not load {@code index.html} until it
175+
* has been served at least once.
172176
*/
177+
@Deprecated(since = "5.5.0", forRemoval = true)
173178
public void initialize(AppShellSettings settings) {
174179
assertFeatureSupported();
175180
assertNotLegacyTheme();

‎base/src/test/java/com/flowingcode/vaadin/addons/demo/AppShellConfiguratorImpl.java‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,8 @@
2020
package com.flowingcode.vaadin.addons.demo;
2121

2222
import com.vaadin.flow.component.page.AppShellConfigurator;
23-
import com.vaadin.flow.server.AppShellSettings;
2423

24+
@DefaultDynamicTheme(DynamicTheme.LUMO)
2525
public class AppShellConfiguratorImpl implements AppShellConfigurator {
2626

27-
@Override
28-
public void configurePage(AppShellSettings settings) {
29-
if (DynamicTheme.isFeatureSupported()) {
30-
DynamicTheme.LUMO.initialize(settings);
31-
}
32-
}
33-
3427
}

0 commit comments

Comments
 (0)