0

I have a HTML widget in my ui.xml which I am using in Uibinder to populate data as given below:

ui.xml ->

 <g:HTML ui:field="operationsDetailTableTemplate" visible="false">
    <table class="{style.LAYOUT_STYLE}" width="100%" border="1">
        <tr>
            <td><img src="images/indent-blue.gif"/></td>
            <td>
                <table class="{style.DEFAULT_STYLE}">
                    <thead>
                           <tr>
                               <th>OperationUuid</th>
                                                    ....
                           </tr>
                     </thead>
                      <tbody>
                            <tr>
                                <td>%s</td>
                                 ...
                             </tr>
                      </tbody>
                  </table>
             </td>
        </tr>
         ....
</g:html>

Uibinder.java--->

 String htmlText = operationsDetailTableTemplate.getHTML()
                   .replaceFirst("%s", toSafeString(operation.getOperationUuid()))
                   ....
 HTML html = new HTML(htmlText);
 operationsDetail.add(html);

The above is done in a for loop for each of the operation retrieved from the database. My question is how I can embed a hyperlink or an anchor tag on one of the cell (eg. operation id ) for each of the operation set retrieved. I also wish to have a listener attached to it.

P.S. - It does not allow me to have a anchor tag in HTML in ui.xml.

4

1 回答 1

0

您最好按照设计使用的方式使用这些工具:ui:field="foo"<td>and @UiField Element foo+上使用,foo.setInnerHTML(toSafeString(...))而不是提取 HTML、修改它并在其他地方重新注入。您也可以使用 a<g:Anchor>并附加 an@UiHandler来处理ClickEvents。

您使用 UiBinder 的方式让我想到SafeHtmlTemplates了新的UiRendereraka UiBinder for Cellshttps ://developers.google.com/web-toolkit/doc/latest/DevGuideUiBinder#Rendering_HTML_for_Cells

于 2012-07-04T00:06:19.387 回答