How to find dataContainer attached to text field?

Hello:

I am building a Composite Component that contains a textField. I would like to access the dataContainer that the text field is linked to from within the code.

I can’t guarantee where this component will be used, so I can’t guarantee that a dataContainer attribute will be set on the field itself. It could be inside a Form or a Table, for example, where the dataContainer is inherited.

I have been searching the docs, but I can’t find any way to access the dataContainer attribute of a textField, nor can I tell how to find one if it is inherited. There used to be dataSource, but this is v7.2 and that is deprecated.

How do I programmatically access the dataContainer associated with a textField?

Hi,
This will work:

    @Subscribe
    public void onAfterShow(AfterShowEvent event) {
        ValueSource<Locale> valueSource = langField.getValueSource();
        if (valueSource instanceof ContainerValueSource) {
            InstanceContainer instanceContainer = ((ContainerValueSource) valueSource).getContainer();
            log.info(instanceContainer.toString());
        }
    }

In legacy screens the field will have DatasourceValueSource instead of ContainerValueSource.

Perfect. Thank you.