开发者

GWT UiBinder any way to have dynamic List of Widgets?

Class Foo has a variable List<Button> bar, how can I render each of the buttons using UiBinder开发者_运维问答? Is it even possible?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜