How to Declare Dependent Style Names with Uibinder

GWT UiBinder style primary name not working

One thing you could do is to create your CSS using ClientBundle, define all the different states there, then handle the various states manually. This way you don't need to define classes as @external, and GWT will optimize the CSS for you (shorten the names, only ship what gets used, etc.). This is especially beneficial for custom widgets and such.

set custom style to GWT CellBrowser with UiBinder

After struggling with it a bit more I decided to create my own widget for it. It can definitely be improved, and I would love to hear suggestions but, by now, it is what I'm using.

This is the structure: CellBrowser > CellPanel[] > Cell[]

  • The CellBrowser widget is initialized with a Cell Array.

  • These cells are placed on the first CellPanel. For each Cell you
    can set a Widget to be displayed on it and a CellPanel that will
    contain its children.

As the whole thing uses a couple files I've uploaded the code as a google code project

Defining optional parameters of a widget with UIbinder

HTMLPanel has a dedicated HTMLPanelParser that processes the element from the ui.xml.

Element parsers are an internal part of UiBinder, you cannot add your own.

You have to declare a single @UiConstructor constructor and have the rest taken care of by setters, with some final validation possibly done in onAttach (similar to how Composite throws at attach-time when you forgot to call initWidget, and similarly for Widget and setElement).

In complex cases, and/or if you want to enforce the use of constructor arguments, then don't do anything special and have users of the widget use a @UiFactory or @UiField(provided = true). This is already the case for SuggestBox, ValueListBox or CellList for instance.

My personal preference goes to that last approach.

Purpose of secondary dependent styles?

Basically the dependent name is more general, since it's calculated at runtime. You can add a dependent name of "highlighted" to any Widget without knowing what it is, and GWT will come up with the appropriate css class name for you. You don't have to hard code button-highlighted, select-highlighted, mycustomthing-highlighted in GWT this way (you do still need to create them all in your css code).



Related Topics



Leave a reply



Submit