include the statement INSTANCE..ensureInjected(); that should fix your problem.
For your reference read the following http://code.google.com/webtoolkit/doc/latest/DevGuideClientBundle.html#ImageResource Overview 1. Write a CSS file, with or without GWT-specific extensions 2. If GWT-specific extensions are used, define a custom subtype of CssResource<http://code.google.com/p/google-web-toolkit/wiki/CssResource> 3. Declare a method that returns CssResource<http://code.google.com/p/google-web-toolkit/wiki/CssResource> or a subtype in an ClientBundle<http://code.google.com/p/google-web-toolkit/wiki/ClientBundle> 4. When the bundle type is generated with GWT.create() a Java expression that evaluates to the contents of the stylesheets will be created - Except in the simplest case where the Java expression is a string literal, it is generally not the case that a CSS file could be generated into the module output 5. At runtime, call CssResource.ensureInjected() to inject the contents of the stylesheet - This method is safe to call multiple times, as subsequent invocations will be a no-op - The recommended pattern is to call ensureInjected() in the static initializer of your various widget type On Mon, Jul 18, 2011 at 11:42 PM, Markus <[email protected]> wrote: > Hello! > > I try to use the ClientBundle implementation to manage my Images to a > large File and minimize the HTTP-Requests. > > I put <inherits name="com.google.gwt.resources.Resources" /> in my > gwt.xml > > Generate the ClientBundle > > public interface ResourceBundle extends ClientBundle { > > public static final ResourceBundle INSTANCE = > GWT.create(ResourceBundle.class); > > @Source("tiles/smiley.png") > ImageResource smiley(); > > } > > The Image would be found, no errors. > > Here is the code > > @Override > public void onModuleLoad() { > > CLogger.log("Start Engine"); > > int width = 800; > int height = 600; > > Canvas canvas = Canvas.createIfSupported(); > canvas.setWidth(width + "px"); > canvas.setHeight(height + "px"); > canvas.setCoordinateSpaceWidth(width); > canvas.setCoordinateSpaceHeight(height); > Context2d c = canvas.getContext2d(); > > Image img = new Image(ResourceBundle.INSTANCE.smiley()); > img.addLoadHandler(new LoadHandler() { > > @Override > public void onLoad(LoadEvent event) { > CLogger.log(event.getSource() + " loaded"); > } > }); > CLogger.log("Visible: " + img.isVisible()); > > c.drawImage((ImageElement) new > Image(ResourceBundle.INSTANCE.smiley()).getElement().cast(), 0, 0); > > RootPanel.get().add(canvas); > > } > > I create a simple Canvas and set the size to 800x600. I create a new > Context2D Object to draw the Image at the Context and add the Canvas > to the RootPanel. > > The logs shows: > > [20:10:21.676] - Start Engine > [20:10:21.851] - Visible: true > [20:10:21.853] - > http://127.0.0.1:8888/engine/7D39451825E9952050F44A6B8E2E15F3.cache.png > > The Image exists under the logged URL so everything looks fine. But > the Image would not be draw or it would draw but not display. > > Anybody an idea? > > I thought the ClientBundle loads the Images as the start in the > backend. So if I get an Instance every Image/Css and others fill be > loaded? > > Regars Markus > > -- > 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. > > -- 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.
