Open mvysny opened 5 years ago
I'm not able to reproduce the issue.
To avoid any external servers and extra maven task influence do this:
What I'm doing is :
@Theme(value = Lumo.class, variant = Lumo.LIGHT)
mvn install
target/project-base-2.0-SNAPSHOT/WEB-INF/classes/META-INF/VAADIN/build/vaadin-bundle-xxx-cache.js
filedocument.body.setAttribute("theme","light")
mvn package
target/project-base-2.0-SNAPSHOT/WEB-INF/classes/META-INF/VAADIN/build/vaadin-bundle-yyyy-cache.js
document.body.setAttribute("theme","dark")
It might be that your resulting WAR file is not updated for some reason ( or WAR deployed to the web server is not a new one but is just the same). Please check that.
@denis-anisimov the bug was filed because it should not be necessary to rebuild WAR in order to change the variant. In other words, the variant change should be applied even when you omit do mvn package
from your steps.
The following command document.body.setAttribute("theme","dark")
in vaadin-bundle-yyyy-cache.js
appears to be generated at Maven compile time from the @Theme
annotation. Is there a reason for that? Shouldn't client-side receive the "dark" String as a parameter from the server and apply it?
Hmm....
I'm not sure how that possible.......
You are deploying a WAR file into the external Web server.
How may you produce a WAR file without doing mvn package
?
I think I'm lost...
Is there a reason for that? Shouldn't client-side receive the "dark" String as a parameter from the server and apply it?
This is a bit out of the scope of my current activity. I'm just trying to make sure that there is an issue via reproducing it. This is the way how it's implemented right now. I don't know the reasons why it's done like it's done.
But I still don't understand how it may come from the server if it's not build with the updated value.
I don't think I understand the ticket at all.
Aha, that's the problem :) I'm not deploying a fully-built WAR to an external Web server. I'm developing an app in Intellij Ultimate, deploying into Tomcat via Intellij's Run configuration. Intellij doesn't need to build the WAR file via Maven in order to deploy exploded WAR into Tomcat. My use-case is that I simply wish to see how the app looks like with the dark theme. So, I stop Tomcat from Intellij, change the annotation, then run the project in Intellij's Tomcat. Intellij doesn't run Maven but uses its own build system to rebuild stuff. Yes, Intellij won't run Vaadin Flow Maven plugin and won't recompile vaadin-bundle-yyyy-cache.js
, that's why the variant is apparently ignored. That's the problem.
However, this issue will plague every customer developing on Intellij (this issue has actually been reported to me from a customer via Expert Chat). Therefore I believe that the theme variant must not be compiled into the cache.js
file.
Alright, now I got this. So this is kind of hot deploy issue. We have a bunch of issues related to this kind of functionality. I will update the title, thanks.
Thanks! Yet I think it's not necessarily a hot-redeploy: you can kill Tomcat, change the annotation and run Tomcat from scratch from Intellij, and the variant change would still not be applied to the app. A cold redeploy if you will :)
Hot deploy issue: happens with IDE (IntelliJ) which is able to reuse something (resources or classes?) from the original project location even though it's deployed to the web server.
Vaadin 14.0.0.rc4
I have the skeleton starter app, with
@Theme(value = Lumo.class, variant = Lumo.LIGHT)
added on theMainView
class. I recompile the project withmvn clean package
and launch the WAR file in Intellij+Tomcat. A white button on white background is properly shown.Now I change the theme variant to dark as follows:
@Theme(value = Lumo.class, variant = Lumo.DARK)
. The theme has not been changed, only the variant. I restart the Tomcat in Intellij, however the dark variant is not applied: the page still uses light theme, as can be seen on thebody
element:<body theme="light">
. I need to runmvn clean package
again, in order to actually activate the dark theme. That doesn't make any sense since the theme is webpacked in in both variants, as can be seen in a browser: simply change the body element to<body theme="dark">
to have the dark theme applied.It should not be necessary to do
mvn clean package
after the variant changes in the annotation - the change should be applied without having to run Maven.