18

The following replaces any current css class names. It appears to call setStyleName.

<g:DecoratorPanel styleName="{style.myCssClass}">

What I really want to do is add a class name, like calling addStyleName.

Is it possible to do what I'm attempting?

antony.trupe
  • 10,640
  • 10
  • 57
  • 84

2 Answers2

29

Use addStyleNames in such situations, like this:

<g:DecoratorPanel addStyleNames="{style.myCssClass}">

It's a little trick I picked up on the GWT's Google Group - too bad it's not (?) mentioned in the official documentation.

PS: I'm actually missing a really comprehensive documentation for UiBinder. I grepped the GWT sources for addStyleNames and found this file: WidgetBasedUi.ui.xml - it seems to contain some interesting use cases for UiBinder, including the one with addStyleNames.
If someone knows any other good/secret references for UiBinder, please share :)

Igor Klimer
  • 15,321
  • 3
  • 47
  • 57
  • 1
    I was close. I tried that, but missed the pluralization of the function name(addStyleName instead of addStyleNames). – antony.trupe Dec 16 '09 at 14:05
  • 2
    The documentation at http://code.google.com/webtoolkit/doc/latest/DevGuideUiBinder.html#Hello_Stylish_World is fairly complete, and mentions the attribute. It is however more of a guide than a reference manual. – Paul de Vrieze Apr 07 '10 at 08:09
3

Yes addStyleNames is the solution. And it is actually mentioned in the documentation: UiObject. See section "Use in UiBinder Templates".

Eduard Wirch
  • 9,785
  • 9
  • 61
  • 73