1
我正在嘗試爲我的GWT CellTable創建自定義單元格渲染器。我試圖在單元格內設置一個CSS樣式,但它不是由於某種原因渲染的。GWT樣式不能在AbstractCell中工作
這裏是我的自定義單元格渲染器
static class MyStringCell extends AbstractCell<String> implements Cell<String> {
interface UncheckedStringTemplate extends SafeHtmlTemplates {
@SafeHtmlTemplates.Template("<div style=\"{0}\"><input type=\"checkbox\"/>{1}</div>")
SafeHtml cell(SafeStyles styles, SafeHtml vendorName);
}
private static UncheckedStringTemplate uncheckedStringTemplate = GWT.create(UncheckedStringTemplate.class);
@Override
public void render(com.google.gwt.cell.client.Cell.Context context, String value, SafeHtmlBuilder sb) {
if (value == null) {
return;
}
SafeHtml vendorName = SafeHtmlUtils.fromString(value);
SafeStyles styles = SafeStylesUtils.fromTrustedString("noaccess;");
SafeHtml rendered = uncheckedStringTemplate.cell(styles, vendorName);
sb.append(rendered);
}
}
這裏的地方我打電話
Column<MyObject, String> userNameSelectedColumn = new Column<MyObject, String>(new MyStringCell()) {
@Override
public String getValue(MyObject myObject) {
return myObject.getName();
}
};
vendorPermissions.addColumn(userNameSelectedColumn, "Objects w/ checkboxes");
此代碼生成這個HTML片段渲染器(注意空的樣式)
<div style=""><input type="checkbox">Vendor 1</div>
所有這一切緊隨the GWT example for Creating Custom Cells,我一直無法弄清楚在哪裏硫s是錯誤的 - 或者如果它是一個錯誤。
但是,我已經使用GWT調試器來檢查呈現的字符串,並且它似乎在其中具有樣式信息 - 所以它在GWT流水線下方的某個點處被刪除,並且在它到達之前我的瀏覽器。
任何想法?