On Fri, Oct 9, 2009 at 8:10 PM, Ray Ryan <rj...@google.com> wrote:

> HTMLPanel handles this case just fine. (See HTMLPanelTest.) But yes,
> UiBinder probably doesn't. I suppose it could do the same trick HTMLPanel
> does--you mind filing an issue?
>
HTMLPanelTest only tests the scenario where TABLE is the root tag. In my
example, TR is the root:

HTMLPanel tr = new HTMLPanel("tr", "<td>hello</td>");


This fails because in HTMLPanel, scratchDiv.getFirstChildElement() returns
null. I can definitely file an issue for this, but it seems that the bug (or
limitation) is with HTMLPanel and UiBinder just inherited this behavior by
means of the copied logic.

> But allocating a widget per row isn't a great plan anyway, it won't scale.
> UiBinder is not a renderer--it's for laying out assemblies of widgets, not
> iterating over data to build them. We don't yet have a tool for that. (Or
> were you thinking in terms of pure DOM objects?)
>
I certainly don't _want_ a Widget per row. A pure DOM hierarchy works fine
as long as no events or "enhanced" functionality is required. More often
than not, however, when displaying a grid of data, there's need for user
interaction, meaning at least some widgets. With UiBinder, this mean a
widget per row. (I suppose it could all be DOM based and the root element
from any required widget could be attached manually. This is complicated and
asking for memory-leaks though)

Anyway, despite the bug in HTMLPanel, I guess the advice is: don't do this
and use a one of the table/grid widgets to dynamically allocate rows?

> Besides FlexTable you might also look at the incubator's PagingScrollTable.
>
On Oct 9, 2009 6:23 PM, "Amir Kashani" <amirkash...@gmail.com> wrote:
>
> HTMLPanel's ability to mimic other tags is limited in that it can't become
> a TR or TD. Following the implementation, it's clear why: placing these
> elements without their requried parent tags into a DIV is invalid so the
> browser never creates the DOM element that HTMLPanel requires. UiBinder is
> similarly limited: the top level tag cannot be a TR or TD, since
> UiBinder.attachToDomAndGetChild copies HTMLPanel's logic.
>
> As a result, it's near impossible to create a TABLE in UiBinder that has a
> dynamic number of rows, a very common use case. The obvious approach is to
> create MyTable.ui.xml that contains a bound TABLE element. Then, in a
> separate file, MyTableRow.ui.xml, define the contents of each row with the
> root element being a TR. This doesn't work for the reason mentioned above. A
> simple workaround is to have MyTableRow.ui.xml have TABLE as it's root
> element, then bind its TR (or retrieve it with getFirstChild) and
> appendChild the row to the TABLE element from MyTable.  This breaks down as
> soon as you want a widget within the rows of a table, however.
>
> As far as I can tell, the only way around this is to use a FlexTable or
> Grid. These work great, except that you lose the ability to define a row
> with complex markup in an XML file.
>
> Unless I'm really missing something, I don't see a good solution here. I
> have some rough idea of how this could be solved with a new table widget
> that can define its rows separately from the outer table, but it's not
> hashed out and probably doesn't fall under the "good idea" category.
>
> Thoughts?
>
> - Amir
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to