3
GWT發電單元提供了以下作爲建設細胞用於CellList
的示例:與UiBinder的
/**
* 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);
}
}
}
如果我有一個複雜的細胞,簡單地從render()
返回一個安全的HTML字符串變成乏味。有沒有辦法爲此使用UiBinder,或者比手動構建HTML字符串更好?