Wednesday, October 31, 2012

Re: I Help help implementing ClickableSafeHtmlCell

If you want your cell to handle events you need to set those events as consumed by defining a constructor like

public ClickableSafeHtmlCell(SafeHtmlRenderer<String> renderer) {
  super(renderer, "click");

But do not reinvent the wheel, is already there (that also is a safehtmlcell).
On Wednesday, October 31, 2012 2:31:58 AM UTC+1, Milan Cvejic wrote:
I am trying to implement ClickableSafeHtmlCell but I can not make it to handle events. I am using Field

    class ClickableSafeHtmlCell extends SafeHtmlCell {

        public void onBrowserEvent(Cell.Context context, Element parent, SafeHtml value, NativeEvent event, ValueUpdater<SafeHtml> valueUpdater) {
            super.onBrowserEvent(context, parent, value, event, valueUpdater);
            if ("click".equals(event.getType())) {

and then creating CellTable column with following code:

        Column<Data, SafeHtml> objectNameColumn = new Column<Data, SafeHtml>(new ClickableSafeHtmlCell()) {
            public SafeHtml getValue(ModuleEntry object) {
                String name = (object.getName() == null ? "" : object.getName());
                String description = (object.getDescription() == null ? "" : object.getDescription());

                String regex = "(<([^>]+)>)";
                return new SafeHtmlBuilder().appendHtmlConstant(
                        "<span>" + name + "</span></br />" + "<span title='" + new SafeHtmlBuilder().appendEscaped(description.replaceAll(regex, "")).toSafeHtml().asString() + "'>"
                                + description.replaceAll(regex, "") + "</span>").toSafeHtml();
and set FieldUpdater for that column:

        objectNameColumn.setFieldUpdater(new FieldUpdater<Data, SafeHtml>() {
            public void update(int index, Data object, SafeHtml value) {

Is there anything that I am missing? Any suggestion is welcome.


You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment