Hi Jens,

Yes, this duplication when extending CssResources is exactly the issue I'm 
trying to highlight above and mitigate with the @required idea. Your 
suggestion is what I was trying to cover with the third option I gave above 
on how to avoid the duplication and unintended precedence override 
(although you do go a bit more in-depth into what it would actually look 
like). And I apologize if I'm giving the impression that this is an active 
issue which I don't know how to workaround or remedy, that's not my 
intention.

I'm trying to say that I've come across this issue several times before, 
and while I'm aware of the cause and the current workarounds/remedies (as I 
try to briefly summarize in the 3 options above), I feel that they are not 
satisfactory enough when considering the scaling and maintenance of large 
webapps. This is why I'm trying to discuss the feasibility and/or 
ramifications of something like the @required because I think it's 
somewhere GWT would be able to shine and facilitate the scalability and 
maintainability of these webapps.

Thanks for you response.

On Friday, February 21, 2014 12:36:08 AM UTC+1, Jens wrote:
>
> 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 google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to