Creating tr / td's with UiBinder, how?

841 views
Skip to first unread message

Andrew Hughes

unread,
Jun 25, 2010, 11:22:58 AM6/25/10
to google-we...@googlegroups.com
I want a template that produces a <tr>. The following doesn't work, but it's what I was hoping for...

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" 
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<tr>
<td><g:Label ui:field="label"/></td>
<td><g:TextBox ui:field="input"/></td>
<td><g:TextBox ui:field="output"/></td>
</tr>
</ui:UiBinder> 


Has anyone worked with <tr>'s in this way before? Seems very similar to http://code.google.com/webtoolkit/doc/latest/DevGuideUiBinder.html#Hello_World which works with a <span> bit this just won't work.


Help would be great thank you!

Chris Boertien

unread,
Jun 25, 2010, 3:02:29 PM6/25/10
to google-we...@googlegroups.com
wrap it with <g:HTML> or <g:HTMLPanel>

> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to google-we...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-tool...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>

Thomas Broyer

unread,
Jun 25, 2010, 7:02:24 PM6/25/10
to Google Web Toolkit


On 25 juin, 17:22, Andrew Hughes <ahhug...@gmail.com> wrote:
> I want a template that produces a <tr>. The following doesn't work, but it's
> what I was hoping for...
>
> <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
> <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
> xmlns:g="urn:import:com.google.gwt.user.client.ui">
>  <tr>
>  <td><g:Label ui:field="label"/></td>
>  <td><g:TextBox ui:field="input"/></td>
>  <td><g:TextBox ui:field="output"/></td>
>  </tr>
> </ui:UiBinder>
>
> Has anyone worked with <tr>'s in this way before? Seems very similar tohttp://code.google.com/webtoolkit/doc/latest/DevGuideUiBinder.html#He...
> which
> works with a <span> bit this just won't work.
>
> Help would be great thank you!

UiBinder works by setting innerHTML on an element, and table parsing
in HTML is very special, which prevents uses of <tr> and <td> outside
a <table> (not to mention that IE throws when you set innerHTML on
some table elements)

Andrew Hughes

unread,
Jun 26, 2010, 5:11:28 AM6/26/10
to google-we...@googlegroups.com
Hi Chris

Unfortunately...

<g:HTML> says "A widget that can contain arbitrary HTML. This widget uses a <div> element, causing it to be displayed with block layout." and <g:HTMLPanel> does the same.

Both of these would end up producing...

<div><tr><td></td></tr></div>

The <div> element WILL break the table.

Thanks for the suggestion tho.

Andrew Hughes

unread,
Jun 26, 2010, 5:14:38 AM6/26/10
to google-we...@googlegroups.com
What do you mean by parsing? Is this done by the UiBinder parsing the ui.xml templates to generate impl code?


--

Thomas Broyer

unread,
Jun 26, 2010, 5:39:27 AM6/26/10
to Google Web Toolkit


On 26 juin, 11:14, Andrew Hughes <ahhug...@gmail.com> wrote:
> What do you mean by parsing? Is this done by the UiBinder parsing the ui.xml
> templates to generate impl code?

No, I mean parsing done by the browser when you assign innerHTML.

i.e. in plain old JavaScript:
var container = document.createElement('div');
container.innerHTML = '<tr><td>foo<td>bar';
// above, the browser parses the string as HTML into a DOM tree, in
the context of the <div> container

Andrew Hughes

unread,
Jun 27, 2010, 7:59:11 PM6/27/10
to google-we...@googlegroups.com
I don't want a <div> - as you point out this won't work... I would like to create a <tr> from UiBinder (with no <div> wrapping it).

Cheers.



--

Thomas Broyer

unread,
Jun 27, 2010, 8:55:31 PM6/27/10
to Google Web Toolkit


On 28 juin, 01:59, Andrew Hughes <ahhug...@gmail.com> wrote:
> I don't want a <div> - as you point out this won't work... I would like to
> create a <tr> from UiBinder (with no <div> wrapping it).

But UiBinder internally uses a <div> to "parse the HTML" (see
UiBinderUtil.fromHtml)

Also, I didn't notice earlier, but you cannot use widgets that way,
they must be included within other widgets (only exceptions: some
custom parsers, and HTML markup inside an HTMLPanel, but they're still
descendant of a widget)
This means you'd have to use an HTMLPanel as the "root" of your
UiBinder. You could try using <g:HTMLPanel tag='tr'><td><g:Label ...></
td>...</g:HTMLPanel> but you'd still have a UiBinder<HTMLPanel,X>, not
a UiBinder<TableRowElement,X>, which changes drastically your "owner
class".

Another possibility, more a hack than anything else, include a <table>
in the UiBinder and then tweak the DOM at runtime to get rid of it
(and its, implicit in markup, <tbody> child).

Njr

unread,
Apr 19, 2014, 12:50:05 PM4/19/14
to google-we...@googlegroups.com
Hi
Mu uibinder contains 
My Uibinder page contains below code

<input name="data" type="text" class="form-control" placeholder="Enter data"  id="data"/>

I want to get data inserted in above textbox in my gwt class using DOM or some other way if any.

so please give me some example to retrieve it.


Thanks

Reply all
Reply to author
Forward
0 new messages