tags:

views:

35

answers:

1

Hi

I'm trying to apply some CSS to my subclass of DialogBox via ClientBundle. When inspecting the DOM I can see an obfuscated class-name got added (class="gwt-DialogBox GF2AVPFBPD") but it does not bear/apply any propertes/changes...

class RegistrationDialog 
  extends DialogBox 
{
  interface MyClientBundle 
    extends ClientBundle 
  {
    @Source("regDlg.css")
    MyCssResource css();
  }

  interface MyCssResource 
    extends CssResource 
  {
    String registrationDialog();
  }

  MyClientBundle myClientBundle = GWT.create(MyClientBundle.class);

  RegistrationDialog()
  {
    add(uiBinder.createAndBindUi(this));
    addStyleName(myClientBundle.css().registrationDialog());
  }
  ...

regDlg.css:

.registrationDialog
{
  background-image: url("logo.png") !important;
  background-color: red !important;
  color: red !important;
  font-size: xx-large !important;
}

What am I missing please?

+1  A: 

You're forgetting to call CssResource.ensureInjected(). From the documentation;

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 types

Check out the answer on this question for more code info.

dagge
Thanks! That was it!
Jaroslav Záruba