Tuesday, January 24, 2012

Re: CssResource - common style - good practice

If this is really for *every* button, then you can use the gwt-Button CSS class name, that's automatically added by each button in the constructor. In a CssResource, make sure you have an "@external .gwt-Button;" line to selectively disable obfuscation for that class name.
That way, you only ever have to inject your CssResource *once* for your whole app.

If you need to keep things "per button", then instead of using the same *.css source in many CssResource (<ui:style> generates a CssResource), which will result in your styles duplicated for each *.ui.xml file (CSS class names would be obfuscated with different names), then create a CssResource interface with the @Source("MyStyle.css"), put it in a ClientBundle, GWT.create() and ensureInjected() it somewhere (e.g. in your onModuleLoad), and then use it in your *.ui.xml with a <ui:with> (see http://code.google.com/webtoolkit/doc/latest/DevGuideUiBinder.html#Using_an_external_resource ).

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/DE1CHAuQL4IJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment