我无法在Vaadin中更改UI的主题

时间:2015-06-09 06:55:54

标签: themes vaadin vaadin7

我正在尝试为Vaadin中的按钮设置新的背景颜色。 但我的UI似乎没有加载mytheme,因为组件松散了它们的外观,看起来像普通的HTML而没有样式。

@Title("My cooool Vaadin project")
@Theme("mytheme")
public class MainUI extends UI {

    @Override
    protected void init(VaadinRequest request) {
        Panel panel = new Panel();

        FormLayout formLayout = new FormLayout();
        Button button = new Button("Press me!!!");
        button.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                System.out.println("BUTTON CLICKED!!!");
            }
        });
        formLayout.addComponent(button);
        panel.setContent(formLayout);

        Window window = new Window();
        window.setContent(panel);
        window.setWindowMode(WindowMode.MAXIMIZED);
        this.addWindow(window);
    }

    @WebServlet(urlPatterns = "/*", name = "MainUI", asyncSupported = true)
    @VaadinServletConfiguration(ui = MainUI.class, productionMode = false)
    public static class UIServlet extends VaadinServlet {
    }
}

我有这个文件结构,因为它在这张图片上:http://i.stack.imgur.com/AWeSz.png

mytheme.scss:

@import "../valo/valo.scss";

@mixin mytheme {
   @include valo;

   /* An actual theme rule */
   .v-button {
     color: blue;
     background: aquamarine;
   }
}

styles.scss:

@import "addons.scss";  /* I also have the addons.scss file*/
@import "mytheme.scss";


.mytheme {
  @include addons;
  @include mytheme;
}

在我的pom.xml中,我有vaadin-client-compiledvaadin-client-compiler,都是最新版本(7.4.3)。当然还有vaadin-themes和所有其他的vaadin依赖。

修改

09:07:36,726 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017534: Registered web context: /vaadinproject
09:07:36,844 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "vaadinproject.war" (runtime-name : "vaadinproject.war")
09:07:37,618 INFO  [com.vaadin.server.VaadinServlet] (default task-31) Request for /VAADIN/themes/mytheme/styles.css not handled by sass compiler while in production mode
09:07:41,538 WARNING [com.vaadin.server.communication.UidlRequestHandler] (default task-2) Invalid security key received from 127.0.0.1
09:07:41,708 INFO  [com.vaadin.server.VaadinServlet] (default task-6) Request for /VAADIN/themes/mytheme/styles.css not handled by sass compiler while in production mode

1 个答案:

答案 0 :(得分:0)

我发现你没有启用productionMode,即productionMode = false并且你的主题没有编译,我猜。

请使用以下命令清理mvn项目:

mvn eclipse:clean并重建您的项目。

有关详细信息,请参阅此处: https://maven.apache.org/plugins/maven-eclipse-plugin/clean-mojo.html