TableFieldFactory field dependencies

Hello.

I have an editable table that uses TableFieldFactory.

I need to know if there is a simple way of updating some fields based on the value changes of a field in the same row. Example:

 
    public Field<?> createField(Container container, Object itemId, Object propertyId, Component uiContext) {

        if (propertyId.equals("fieldA")) {
            Field fieldA = new FieldA();
            fieldA.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(Property.ValueChangeEvent event) {
                    // DO SOMETHING ON FIELD B, like changing the number of selectable options
                }
            });
            return fieldA;
        } else if (propertyId.equals("fieldB")) {
           return  new FieldB();
        } 
    }

Thank you.

You probably need to cast the uiComponent to a Table (or otherwise get a reference to it), ask for the field B from it and then perform the changes.

If modifying values of other fields, be careful not to do it too early in initialization - if you do, the values you set might get overwritten by the framework with values from the container before you see your changes.

Unfortunately we ran into the same problem here. We use a TableFieldFactory to get ComboBox A and ComboBox B. In the ValueChangeListener of ComboBox A we try to set values to ComboBox B according to the selected value in ComboBox A. Could you elaborate on how to retrieve ComboBox B from the table?

We use a BeanItemContainer to hold the values of the table. In the BeanItem we only store the selected value of the ComboBox so we cannot use the BeanItem to retrieve the ComboBox B where we want to set the ContainerDataSource.

We need to find a way to access the ComboBox B from the table itself. Thank you very much!