Sorry me, I am new to Vaadin, and I can’t get
mytheme/styles.css
working.
In other words, what is documented on
https://vaadin.com/book/-/page/themes.creating.html
did not work for me.
I use Vaadin 7.0.0.beta11, built from Maven archetype like the following:
mvn archetype:generate -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-application -DarchetypeVersion=7.0.0.beta11 -DgroupId=at.workflow.webdesk -DartifactId=vaadin -Dversion=1.0 -Dpackaging=war
mvn package eclipse:eclipse
Then I created a
VAADIN/themes/mytheme
folder and put following
styles.css
into:
@import "../base/styles.css";
.v-label {
background: cyan;
}
I used the @Theme annotation to set mytheme. Here is my UI Java class:
@Theme("mytheme")
public class MyVaadinUI extends UI
{
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
Button button = new Button("Click Me ...");
button.addClickListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
layout.addComponent(new Label("Thank you for clicking"));
}
});
layout.addComponent(button);
}
}
All done like documented in the tutorial mentioned above.
The I did a
mvn jetty:run
in the project’s base directory and entered http://localhost:8080 in my web browser.
Result: the UI looks completely unstyled!
Expected was: the UI has all inherited
base
styles, just the label is cyan.
Even when I leave out the
.v-label { background: cyan; }
CSS statement, the UI is completely unstyled,
the @import directive seems to not work!
Replacing the import with
@import “…/reindeer/styles.css”
did not help either.
I try to explain
“unstyled”
by words:
- The button “Click Me …” has no button border, does not look/behave like a button at all, both button and labels extend from left to right browser edge, neither has insets or margins. The cyan color proves that the @Theme was processed. A CSS check with browser debugger shows that none of the
base
CSS properties arrived in HTML code. - When
not
using
mytheme
, the button has a rounded border, looks like a button, and does not extend from left to right browser edge. Of course labels are not cyan.
So here is my question:
what have I done wrong?
First screenshots uses “mytheme” (shows as it looks), second has no explicit theme (shows as it should look).
_