If you write a widget and that widget uses a button and that button has a
default style defined in a BaseCssResource then you should use that
BaseCssResource directly in your widget. You should not make your
WidgetCssResource extend the BaseCssResource. Why? Because as soon as you
do so, all the CSS rules of BaseCssResource will be duplicated (even if the
BaseCssResource is annotated with @Shared, which will cause the issue you
describe) and that is not what you want. Imagine you have 50 widgets and
each of their CssResources extends the BaseCssResource. You would end up
with 50 times the same base CSS code injected in your html page (either
with the same CSS class names if you use @Shared on your BaseCssResource or
with different CSS class names if not).
What you should do in all your widgets is:
<ui:with field="bundle" type="...." />
<ui:style>
.redbutton { background-color:red; }
</ui:style>
<button class="{bundle.baseCss.button} {style.redbutton}">
And in your custom widget constructor you would do
public MyWidget() {
bundle.baseCss().ensureInjected();
}
That way your base CSS is only injected once into your HTML page and all
your widgets use these rules directly instead of duplicating them over and
over again. It is also clear, just by looking at the xml/code, that the
base CSS is shared by multiple widgets and that the <ui:style> CSS is only
local to that single widget.
-- J.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.