GWT / UIBinder how to find the main css file using <ui: style>
I am trying to create a gwt site with UIBinder. It's cool, it works, but I have a problem with ui: style.
My project is stunned (I am using the gwt-maven-plugin archetype).
The Application.html and Application.css files are located in the src / main / resources / com / foo / bar / public file.
The page I'm trying to create is in the src / main / java / com / foo / bar / client / Page1.java and Page1.ui.xml file.
I can use the css file if it is in the same package with:
<ui:style src="Page1.css" /> But I would like to target Application.css (so that I could avoid using the same styles in every css file in every package)
I tried different relative paths and Application.css was never found.
Is there someone who has the same problem and would like to help me?
Thanks!
If your css application is referenced elsewhere in the ClientBundle, you can use and generally avoid problems with your path. See Using an external resource .
Old question, but; I just referenced a global style like this without the ui: style directive:
g: TabPanel ui: field = "tabPanel" width = "100%" height = "90%" styleName = "nameInMyMainCss"
This is equivalent to calling setStyleName ("nameInMyMainCss"); in the corresponding java class.
You should consider whether this is really what you want to do. UiBinder uses css through the ClientBundle mechanism, which optimizes css, obfuscates style names, and then embeds styles as part of your compiled JavaScript code. If you then also use the same css file in the traditional way (with the <link> ), then you will need your users to download the same CSS rules twice. In practice, the lag may not be too noticeable, but in principle it is a little bad.
In any case, this is not possible, since the ClientBundle (and, therefore, UiBinder) only works with css files in your source folders. As gk5885 says, you can create a single ClientBundle and use it throughout the entire project by including it in your UiBinder templates. You should consider moving as much css as possible to this system.