how to edit table column of Lable

I have a table with this setup:
(feedslist is the table)

        feedslist.addContainerProperty("URL", Label.class, null);
        feedslist.addContainerProperty("Scan", Integer.class, null);
        feedslist.addContainerProperty("Fail", Integer.class, null);
        feedslist.addContainerProperty("Rel", Integer.class, null);
        feedslist.addContainerProperty("Irrel", Integer.class, null);
        feedslist.addContainerProperty("Excl", Integer.class, null);
        feedslist.addContainerProperty("Dups", Integer.class, null);
        feedslist.addContainerProperty("delete", Button.class, null);

I want to edit the “URL” column when feedslist.setEditable(true), how am I suppose to setup the TableFieldFactory ?

what I have now is:

feedslist.setTableFieldFactory(new TableFieldFactory() {
            
            @Override
            public Field<?> createField(Container container, Object itemId, Object propertyId, Component uiContext) {
                // TODO Auto-generated method stub
                String pid = (String) propertyId;
                if(pid.equals("URL")){
                    // how am I suppose to setup things here?
                    TextField field = new TextField();
                    field.setImmediate(true);
                    return field;
                }else{
                    TextField field = new TextField();
                    field.setImmediate(true);
                    return field;
                }
            }
        });

I suppose I should some how setup the TextField but I have no idea how. Could anyone help please?

Hi!

First of all, you should probably have

feedslist.addContainerProperty("URL", String.class, null); instead of

feedslist.addContainerProperty("URL", Label.class, null); because that type parameter in there means the type of data you have, not the type that gets displayed. Buttons you can’t add through a field factory either, so at least for that you might want a column generator instead, e.g. like this:

        feedslist.addGeneratedColumn("delete", new Table.ColumnGenerator() {

            @Override
            public Object generateCell(Table source, Object itemId,
                    Object columnId) {
                return new Button("Delete", new Button.ClickListener() {

                    @Override
                    public void buttonClick(ClickEvent event) {
                        // TODO delete
                    }
                });
            }
        });

As for field factories, if you’d like to make the URL field editable and keep all the other fields as labels, your createField could look e.g. like this:

@Override public Field<?> createField(Container container, Object itemId, Object propertyId, Component uiContext) { TextField field = new TextField(); if (!"URL".equals(propertyId)) { field.setReadOnly(true); } return field; } …but if you want to do anything more complicated and don’t want to implement your own field creation for everything, you might instead want to extend DefaultFieldFactory and let it handle the rest of it, e.g. like this:

    public class MyFieldFactory extends DefaultFieldFactory {

        @Override
        public Field<?> createField(Container container, Object itemId,
                Object propertyId, Component uiContext) {
            if ("URL".equals(propertyId)) {
                return new TextField();
            } else {
                return super.createField(container, itemId, propertyId,
                        uiContext);
            }
        }
    }

.