1

I have like one client bundle :

public interface FirstClientBundle extends ClientBundle {

  public static final FirstClientBundle INSTANCE = 
  GWT.create(FirstClientBundle.class);

  @Source("panel-top-bg.png")
  public ImageResource panelTopBg();
}

and I'd like to use image from first Bundle in styles of another Bundle. Something like this:

public interface SecondClientBundle extends ClientBundle {

  public static final SecondClientBundle INSTANCE = 
  GWT.create(SecondClientBundle.class);

  public interface Style extends CssResource {
    @ClassName("panelTop")
    String panelTop();
  }

  @Source({ "style.css" })
  public Style style();
}

end the CSS file looks like:

@sprite .panel-top {
  gwt-image: "FirstClientBundle.panelTopBg";
  height: 18px;
  cursor: move;
}

Is it even possible? Or should I do whole thing differently?

Sebastian Piskorski
  • 4,026
  • 3
  • 23
  • 29

1 Answers1

0

Could you write the second ClientBundle as a subinterface of the first one?

public interface SecondClientBundle extends FirstClientBundle
slugmandrew
  • 1,776
  • 2
  • 25
  • 45
  • Ups, there should be SecondClientBundle instance there. And I'd rather not use inheritance in this case, because I should then extend SecondClientBulndle by more than one interface. – Sebastian Piskorski Mar 14 '14 at 21:54
  • Although its one of solutions, I think it could make code messy. – Sebastian Piskorski Mar 14 '14 at 22:00
  • I don't get why inheritance is not what you want because it is 'messy'. Can you explain why, or what kind of solution you want? – slugmandrew Mar 17 '14 at 10:03
  • I don't think that inheteritance is needed here so I'd like to aviod it. Here it is explained pretty good: http://www.javaworld.com/article/2076814/core-java/inheritance-versus-composition--which-one-should-you-choose-.html – Sebastian Piskorski Mar 17 '14 at 13:15
  • I understand the difference, but I think here you are limited to what GWT can actually do and what it can't do. From http://www.gwtproject.org/doc/latest/DevGuideClientBundle.html: "@sprite is sensitive to the FooBundle in which the CSSResource is declared; a sibling ImageResource method named in the @sprite declaration will be used to compose the background sprite." – slugmandrew Mar 17 '14 at 14:14