Why doesn't my call to TableSectionElement.setInnerSafeHtml() get rendered to the DOM?

23 views
Skip to first unread message

Matthew McLarty

unread,
Apr 4, 2018, 3:36:43 PM4/4/18
to GWT Users

I have a legacy application that uses UIBinder to render the UI. I am trying to spit out records into a standard element. In my view.ui.xml file, I have a table with my semantic element setup and a element with the appropriate ui:field.

<table>
  <thead>
    <tr>
      <th>&nbsp;</th>
      <th>Customer #</th>
      <!-- Shortened for brevity -->
    </tr>
  </thead>
  <tbody ui:field="tbody"><!-- Note the ui:field defined -->
  </tbody>
</table>

In my view.java class, I have that ui:field coupled to a TableSectionElement.

public class View extends Composite implements ViewPresenterInterface {
    @UiField TableSectionElement tbody;
    public TableSectionElement getTbody() {
      return tbody;
    }
}

In my class that handles rendering the table elements, the code is fairly straight-forward:

private void renderOrderTable() {
        List<OrderToReviewProxy> sortedList = sortOrders(orders);
        SafeHtmlBuilder sb = new SafeHtmlBuilder();
        for(OrderToReviewProxy order : sortedList) {            
            sb.appendHtmlConstant("<tr>");
            sb.appendHtmlConstant("<td>");
            sb.appendEscaped(order.getCustomerNumber());
            sb.appendHtmlConstant("</td>");
            sb.appendHtmlConstant("</tr>");
        }
        view.getTbody().setInnerHTML(""); // Breakpoint A

        view.getTbody().setInnerSafeHtml(sb.toSafeHtml()); // Breakpoint B
    }

At Breakpoint A, inspecting view.getTbody() shows me the <tbody></tbody> element empty, as expected. Stepping over Breakpoint B, inspecting view.getTbody() shows me the <tbody> element with the expected HTML that the SafeHtmlBuilder generated during the for loop.

However, when I look at the rendered page, the <tbody> element has no child nodes. None of the HTML from calling sb.toSafeHtml() seems to get written into the DOM. Can anyone help me out here? I have no idea why this isn't working.


I asked this question on StackOverflow as well, in case anyone wants extar points for answering it there. I am stumped!

https://stackoverflow.com/questions/49658953/gwt-why-doesnt-my-call-to-tablesectionelement-setinnersafehtml-get-render


Reply all
Reply to author
Forward
0 new messages