add class name to element in uibinder xml file

大兔子大兔子 提交于 2019-12-03 15:19:55

问题


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?


回答1:


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 :)




回答2:


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



来源:https://stackoverflow.com/questions/1899007/add-class-name-to-element-in-uibinder-xml-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!