I'm attempting to create a custom cell renderer for my GWT CellTable. I'm attempting to set a CSS style inside of the cell, but it's not rendering for some reason.
Here's my custom cell renderer
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);
}
}
And here's where I'm calling the renderer
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");
This code produces this HTML fragment (notice the empty style)
<div style=""><input type="checkbox">Vendor 1</div>
All this closely follows the GWT example for Creating Custom Cells and I haven't been able to figure out where this is going wrong - or if it's a bug.
I have, however, used the GWT debugger to examine the rendered String and it does seem to have the style information in it at that point - so it's getting removed at some point further down the GWT pipeline and before it gets to my browser.
Any ideas?