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
How to Make an Inset Drop Shadow in Svg
Django Templates: Group Items in Threes
Does :Not() Negation Accept Descendant Selectors
Less Loops Used to Generate Column Classes in Twitter - How Do They Work
Custom Li List-Style with Font-Awesome Icon
How to Make Card-Columns Order Horizontally
CSS Select Multiple Descendants of Another Element
Why Is Filter(Drop-Shadow) Causing My Svg to Disappear in Safari
How to Apply Child:Hover But Not Parent:Hover
Select Specific Element Before Other Element
Select Menu Option Border None
CSS Background-Position Not Working in Mobile Safari (Iphone/Ipad)
CSS - Is There a Cousin Selector
Label on the Left Side Instead Above an Input Field
Font-Awesome Not Working Bundleconfig in MVC5
Row Wrap in Flex-Box Not Wrapping in Safari
Firefox Sets Wrong Caret Position Contenteditable with :Before