GWT/UIBinder how to find the main css file with <ui:style>
I'm trying to build a gwt website with UIBinder. It's cool, it works, but i have a problem with ui:style.
My project is mavenized (i use the gwt-maven-plugin archetype).
The Application.html and Application.css files are in src/main/resources/com/foo/bar/public.
The page i'm trying to style is in src/main/java/com/foo/bar/client/ Page1.java and Page1.ui.xml.
I can use a css file if it is in the same package with :
<ui:style src="Page1.css" />
But i'd like to target the Application.css (so i could avoid having the same styles in each css file in each package)
I tried different relative paths, and the Application.css is never found.
Is there someone, out there,开发者_StackOverflow who had the same problem, and would care to help me ?
Thanks !
If your application css is referenced elsewhere in a ClientBundle you can use and avoid your path problems altogether. See Using an external resource.
Old question, but; I simply 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 matching java class.
You should think about whether this is really what you want to do. UiBinder uses css through the ClientBundle mechanism, which optimizes the css, obfuscates the style names, and then embeds the styles as a part of your compiled javascript code. If you then also use the same css file in the traditional way (with a <link>
tag) then you are requiring your users to download the same css rules twice. In practice the lag might not be too noticeable but in principle it's a bit poor.
In any case this isn't possible, as ClientBundle (and therefore UiBinder) only works on css files in your source folders. As gk5885 says, you can create a single ClientBundle and use it project-wide by including it in your UiBinder templates. You should consider moving as much css as you can into this system.
精彩评论