問題はすべてですが、GWTでCellTableを使用して、キャンバスを含むカスタムセルを作成するにはどうすればよいですか?
キャンバスをhtmlに変換して、renderメソッドのSafeHtmlBuilderパラメーターに追加する方法を探しましたが、成功しませんでした。カスタムセルの興味深いスニペットは次のとおりです。
public void render(Context context, String value, SafeHtmlBuilder sb) {
Canvas c = Canvas.createIfSupported();
// create a text into the canvas using the value parameter
// something like (this is not important) :
c.getContext2d().drawTheText(value);
// here is the problem, what kind of transformation may I do
// to use the canvas in this cell ?
SafeHtml safeValue = SafeHtmlUtils.fromString(c.?????);
sb.append(safeValue);
}
編集:トーマスのおかげで、これが実用的な解決策です
sb.append(SafeHtmlUtils.fromTrustedString("<img src=\"" + canvas.toDataUrl() + "\" />"));
HTMLコードを直接使用するのではなく、テンプレートを使用する必要があることに注意してください。