Adding a url column in celltable gwt

88 Views Asked by At

I'm workin on a web app using gwt, I have a celltable with textcolumns I want to add a column that will contain links, once the user clicks on a cell of this column he is forwaded to the link.

How can I do such a thing in gwt?

1

There are 1 best solutions below

0
Gunnar Berg On

You would have to use a cell of appropriate type such as ClickableTextCell or ButtonCell as well as a FieldUpdater.

Basically you can add a FieldUpdater to your column as such:

column.setFieldUpdater(new FieldUpdater<YourObject, String>() {
        @Override
        public void update(int index, YourObject object, String value) {
            Window.open(value, "_blank", ""); //This will open link in a new tab or window
        }
    });

Where value in this case is the url. update() will be called when the column is clicked.