On Dec 9, 4:36 pm, Eric Landry <[email protected]> wrote:
> Hi,
>
> I'm trying to get my app working with GWT2 and was wondering if
> there's anything wrong about the following code:
>
> public interface MyImages extends ClientBundle {
>     public static final MyImages INSTANCE = GWT.create
> (MyImages.class);
>
>     @Source("small.png")
>     ImageResource logo();
>
> }
>
> public class Foo {
>     public Foo() {
>         Image img = new Image(MyImages.INSTANCE.logo());
>     }
>
> }
>
> Is it acceptable to keep all my images in one ClientBundle? Is there a
> better way to do this? Thanks in advance!

That's exactly how I moved from ImageBundle/AbstractImagePrototype to
ClientBundle/ImageResource when upgrading our "legacy" app from GWT
1.7 to GWT 2.0.
We have one ClientBundle per "feature" (feature==package, in our app)
though, and an additional "global" ClientBundle for shared images. But
we finally have a ClientBundle inheriting all others and only this one
is instantiated, so we only have a single PNG image being generated.

In our new app, we're using dependency injection (through GIN) so I
don't have that INSTANCE constant (we just let GIN make the GWT.create
() for us). And we've also moved to having many "small" ClientBundle
with limited "scope" (one per "screen", plus a bunch of "shared"
ones).

AFAICT, given how this is all compiled, it shouldn't have any overhead
*in your code* whether you use one big ClientBundle or several small
ones, and whether they are singletons or you have many instances of
the same ClientBundle floating around (everything will be converted to
"static methods" or even constants by the compiler's optimizations).
I put emphasis above on "in your code", because for IE6/7, each
ClientBundle (class/interface, not each instance) will generate one
"sprite image", just like ImageBundle in previous GWT versions.

In fine, the choice of instantiating a single big ClientBundle (not
necessarily as a singleton though) or several smaller ones will depend
one the performances you'll measure, primarily on the network (in
IE6/7, the less you have bundles, the less it'll generate HTTP
requests, but each HTTP response will be be bigger).
Same goes for GWT.runAsync, and the use of ClientBundle with styles
(*and* in combination with GWT.runAsync)

--

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.


Reply via email to