GWT UiBinder any way to have dynamic List of Widgets?

你。 提交于 2019-12-10 01:44:48

问题


Class Foo has a variable List<Button> bar, how can I render each of the buttons using UiBinder? Is it even possible?


回答1:


UiBinder is a XML template for declaratively laying out widgets and is not a renderer. Hence you cannot have conditionals, loops and other logical constructs within the UiBinder XML.

What you can instead do is have a Panel in the UiBinder as mere placeholder for where you would like all your buttons to go. Have a ui:field reference to this panel in your Java class. Loop through the button list and add buttons to the panel in java code, using the field handle.

Other approach would be to define a composite and add the composite in the UiBinder, and let the composite do the rendering of the buttons by itself. Just depends on what is best suitable for your design.



来源:https://stackoverflow.com/questions/3131141/gwt-uibinder-any-way-to-have-dynamic-list-of-widgets

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