I am brand new too GWT, and no matter how much I read the official doc on ClientBundle
s I just can't seem to wrap my head around what they are, and what they do. The same goes for CssResource
, DataResource
, TextResource
, GWTCreateResource
, etc.
I think they exist as some kind of performance optimization for static files (such as CSS, JavaScript, or some static data source like a JSON file). Apparently, they are also "injectable", which doesn't make sense to me if they are supposed to be static CSS/JS/JSON/etc. files...
So I ask: can someone please give me a down-to-earth, simple, King's English, simple, explanation of what these objects are, and how they're used? Could I be so bold as to ask for a working example of this injection in action (the code snippet in the link above talks about injection but never actually shows it!)? How do these map to the actual files (my-styles.css
, dataTable-static-data.json
, etc.)? In fact, I think that's my biggest mental hurdle: tying these Java objects to the static files they represent.
Also, why bundle? Reusability across other projects? Maybe that's where the injectability comes into play? I'm so confused.
They solve lots of problems:
Your CSS is compile-safe. If you use a css-class, that does not exist, the compile will show you which class does not exist
Your CSS is name-safe. If you have two different widgets, which uses the same css-classname, the compiler ensures, that your widget "A" class does not corrupt the widget "B" css
You compile images automatic into data-url or sprite images. This will reduce tghe amount of http-calls.
Take a look at the goals: https://developers.google.com/web-toolkit/doc/latest/DevGuideClientBundle