I have written a pill-buttonbar using just flow, just Java code. It requires some CSS of course, and I would like to move the whole thing into a separate jar. I think I need to use CssImport and put the css src/main/resources/META-INF/resources/frontend/…, but it ain’t working. I don’t see a request for the CSS in the browser’s network tab. And then I probably need to do something with special CSS selectors.
A simple example, which one can copy and modify, would be preferable over all the documentation. At least to get started. Is there such a thing?
The src/main/resources/META-INF/resources/frontend/ is correct for JAR packaged component.
Where exactly is the CSS file and how does the @CssImport definition look like?
Also, if the JAR is used as a dependency of a Spring-based project, make sure you do not have (allowed|blocked)-packages setting in application.properties that prevents class scanning for your component.
@knoobie That is what I tried, at least you have confirmed that it is still correct (I found a Vaadin 14 example - not sure if it was still valid). Should this also work while to component is still part of the actual project? So not in a separate jar yet?
If the component is in a separate jar, @CssImport is the correct way to import your CSS.
If the CSS is not found then the application won’t start. @CssImport("./the-addonsdsd.css")
Failed to find the following css files in the `node_modules` or `/Users/jean-christophe/Documents/cf/addon-starter-flow/src/main/frontend` directory tree:
- ./the-addonsdsd.css
Check that they exist or are installed. If you use a custom directory for your resource files instead of the default `frontend` folder then make sure it's correctly configured (e.g. set 'vaadin.frontend.frontend.folder' property)
If it’s inside your main module, it’s easier to use the theme and import it from the theme.
Or you can use CssImport and add it in /src/main/frontend/the-addons.css
If it’s inside you project in a different module then it’s treated like a addon.
Again if it’s not found it should throw an exception.
Maybe if you have an example it would be easier to help you to find the issue.
your button css selector might be problematic because it would not work as you think (especially the first and last selector) - you should group all of those e.g. with a parent selector
did you also add @EnableVaadin(value={“org.tbee.webstack.vdn.component”, “your.main.class.package.”}) to your Application.java where you wanna use this addon?
Yes, I understand that I need some more work on it to make it a full custom component. For now it worked on the screen I was using it on and I just copied it over to a component, unchanged, to reduce the chance of breaking something.
No, I did not include that EnableVaadin annotation. I have in fact never used it, and I’ve written about 5 Spring based Vaadin applications, and never needed it, some mixing Thymeleaf into Vaadin even. I added it just now, and the application starts, but refused to navigate to the view annotated with @Route(“/”) with a “Could not navigate to ‘’”. Without the annotation the application runs fine. Reading the annotation’s javadoc it is a mystery that I don’t need it.
We use cookies to serve our customers and website visitors in the best possible way. Cookies are used for the proper functioning of the website and for improving the user experience, monitoring visitor traffic and marketing purposes. By continuing to browse the site, you agree to our use of cookies. You can read more about cookies here.
We use cookies to serve our customers and website visitors in the best possible way. Cookies are used for the proper functioning of the website and for improving the user experience, monitoring visitor traffic and marketing purposes. By continuing to browse the site, you agree to our use of cookies. You can read more about cookies here.