> Because noone took the time to do it? (and GWT being a toolkit, it has
> to account for both backwards and forwards compat, so it must be well
> thought out from the beginning)
That's understandable, but still, like you mention below, they do use
it widgets like Tree, etc..
> What's the problem? If you call setStylePrimaryName or
..
> I haven't tried it, but passing some specializedCssResourceor
Please try it and use CssResource in a resuable widget, and you will
see that it's much harder then you think (otherwise I wouldn't ask..)
I started just like you mention "what's the problem", must be 123
finish... I found out otherwise..
> GWT already uses ImageResource and ClientBundle (when multiple
> ImageResources are needed), and it shouldn't be really different with
> aCssResource. Have a look at Tree and its Tree.Resources, MenuBar and
I know the GWT usage, and these only use the Client bundle, not the
CssResource!
And the CssResource usage is much harder...
My question: best practices of the CssResource in reusable widgets...
The doc explains the theory but is missing good examples.
Let me explain my "problem" through a use case:
Suppose we have a MyButton that needs an image and style and that we
can inject the client bundle through the constructor:
MyButton() {
this(GWT.create(MyButtonClientBundle.class));
}
MyButton(final MyButtonClientBundle resource) {
this.resource = resource;
}
The client bundle:
MyButtonClientBundle extends ClientBundle{
@Source("back.png")
ImageResource back();
@Source("mybutton.css")
MyButtonCssResource getCss();
}
And:
MyButtonCssResource extends CssResource {
@ClassName("but")
String button();
}
And the mybutton.css contains:
.but {
background-color: #ff00ff;
}
Some developer comes along and likes to use the MyButton and change
the background color. How can he do this?... I donnoo :(...
The problems I see:
- He has to extend MyButtonClientBundle with his own version,
something like ReuseClientBundle that he specifies through the
MyButton constructor... He will override the method getCss and
specifies his own stylesheet.
However the compiler will see two getCss() methods and will load both
stylesheets, which is not be desirable as he want to set his own
background color.
How to deal with this?
An idea would be to only inject the MyButtonResource in MyButton, but
then we are missing the ImageResource that MyButton needs :( ..
- Suppose that he don't want to change the background color, but just
some padding.
In this case he will not have a problem with the injection witht he
sylesheet through MyButtonClientButton, as it doesn't set the padding,
but how do you share the same obfuscated name such he can inject his
own stylesheet that contains something like:
.panel .but {
padding: 10px;
}
I did this, and it won't work as the style set in MyButton that comes
from MyButtonCssResource has a different obfuscated names. I could
solve this by the @external annotation, but that is for legacy code,
and mine is brand new.. :(..
I think that it might be solved through the @Share or @Import
annotation, but I don't fully understand that...
It's lot of text above, but I hope some of the problems are clear now.
Ed
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.