GWT 提供以下作为为 a 构建单元的示例CellList
:
/**
* A simple data type that represents a contact.
*/
private static class Contact {
private static int nextId = 0;
private final int id;
private String name;
public Contact(String name) {
nextId++;
this.id = nextId;
this.name = name;
}
}
/**
* A custom {@link Cell} used to render a {@link Contact}.
*/
private static class ContactCell extends AbstractCell<Contact> {
@Override
public void render(Context context, Contact value, SafeHtmlBuilder sb) {
if (value != null) {
sb.appendEscaped(value.name);
}
}
}
如果我有一个复杂的单元格,那么简单地返回一个安全的 HTML 字符串render()
会变得乏味。有没有办法为此使用 UiBinder,或者比手动构建 HTML 字符串更好的方法?