简体   繁体   中英

how can i make my css file available for my entire application in Gwt?

I'm using GWTP and Maven, i have a .css file which specifies different styles for the widgets in my application, and my application has some sub modules also so my question is how can i make my css available for the whole application ? how can i make my css file available for sub modules also?

To benefit from GWT's CssResource advantages (like you do when you say <ui:style src="abc.css"/> ) you'll have to use a ClientBundle.

ClientBundles are basically Java classes that represent CSS and other resources. Without GWT, you'd put your CSS and images directly into your HTML code. With GWT, you want to do everything through Java... and that means using Java design patterns.

As you know, you can't just use a global variable in Java programs, and the same is true for css with GWT. You'll have to pass your CSS classes to your libraries as Java objects. You can use static references in many places, but I prefer to actually pass in CSS objects to maximize flexibility later, and I think that's an established best practice.

TL;DR:

Figure out ClientBundles and do as you'd normally do to pass Java variables between libraries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM