How to mix HTML and GWT widgets using UIBinder?
Asked Answered
F

2

5

We have an existing UI built with UIBinder whose ui.xml file contains the following hierarchy:

<ui:UiBinder>
<div>
Multiple <span> or <a> separated by verbatim HTML (like | separators).

I need to replace one of the anchors with a listbox.

Is there a way to make this transition without replacing the div with an HTMLPanel and changing all the anchors to something else?

If I try to stick a gwt:ValueListBox or gwt:ListBox in there, I get an error message that I cannot mix the two. I also cannot have multiple children (such as a div and an HTMLPanel) under the UIBinder.

If my only option is to convert everything to widgets, what are the appropriate conversions for and items?

Face answered 27/6, 2011 at 14:24 Comment(1)
why don't you add an HTMLPanel to the binder and then put your div and the rest of your HTML inside ?Procaine
S
14

In UIBinder, HTMLPanel can contain HTML elements and GWT widgets, but HTML elements can only contain other HTML elements.

Just replace top-level div with HTMLPanel, then replace only a specific <a> anchor with gwt:ListBox.

Schenck answered 27/6, 2011 at 14:51 Comment(2)
…and of course, in your Java code, you'd probably have to extends Composite and initWidget rather than extends Widget and setElement.Gualterio
from HTMLPanel javadoc: "A panel that contains HTML, and which can attach child widgets to identified elements within that HTML." - this suggest that HTML elements can in fact contain WidgetsAvouch
S
1

Like this

<gwt:HTMLPanel>
    <div align="center">
        <gwt:VerticalPanel res:styleName="style.background">
Sensillum answered 14/12, 2015 at 7:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.