Tuesday, October 30, 2012

I Help help implementing ClickableSafeHtmlCell

Hi,
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())) {
                Window.alert("bla");
            }
        }
    }

and then creating CellTable column with following code:

        Column<Data, SafeHtml> objectNameColumn = new Column<Data, SafeHtml>(new ClickableSafeHtmlCell()) {
            @Override
            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) {
                Window.alert(value.asString());
            }
        });

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

Thanks,
Milan

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/DGsQSSOG8pMJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment