Refresh a treetable with HierarchialContainer data source

Hi everyone,

I have a treetable with hierarchial container as data source container set in editable mode. I want to refresh the table when the value of a property changes so that the other fields dependent on that property can be updated in UI. We have refresh() method for JPAContainer is there anyway to do that for hierarchial container.

Thank you.

If I’m not mistaken JPAContainer#refresh fetches data from database and refreshes your whole container. In that sense the the equivalent for HierarchicalContainer (and IndexedContainer) is just to update every item manually one by one or simply just build a new container datasource and set it as the datasource of the Table/Treetable. If you know that changed property is depended for example only by the children or parent, you can limit the amount of updates to avoid potentially costly full refresh of datasource. But anyways you have to handle the logic by yourself.

Hi Johannes,

My actual problem is I have a column generated with checkbox in the table. When the checkbox is checked all the other checkboxes in that column should be unchecked. I am changing the property value of that column in each row in the checkbox valuechangelistener but not committing to the database.Eventhough property value is changed the checkboxes still remain checked. sample code here

           CheckBox cb = new CheckBox();
            cb.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(ValueChangeEvent event) {
                    if(event.getProperty().getValue().toString().equals("true")){
                        for(Object itmId : source.getItemIds()){
                            if(!itmId.equals(itemId)){
                                source.getItem(itmId).getItemProperty(columnId).setValue("N");
                                source.getColumnGenerator(columnId).generateCell(source, itmId, columnId);
                            }
                        }
                        prop.setValue("Y");
                    }else{
                        prop.setValue("N");
                    }
                }
            });
            if(prop.getValue()!=null){
                if(prop.getValue().toString().equals("Y")){
                    cb.setValue(true);
                }else {
                    cb.setValue(false);
                }
            }
            return cb;

Sorting the column by clicking on the header refreshes the values.So can i refresh the data only in the UI like sorting does.

Thank you.