How to implement the afterSelect for the LookupPickerField

How to get the selected instance in the LookupPickerField. I want to implement it from afterSelect method using Action. Please guide me how to do it…

Thanks…

Hi!

afterSelect() method takes a collection of selected items there is no need to do other logic. Or you mean how to extend LookupAction and get the selected item?

Actually i want to clone the selected items in the entity, when it is been selected from the lookuppickerfield…

If I understand correctly, there is no need to clone a selected item if you use Datasource it will save changes in the entity automatically. Or you can use value change listener and handle changes manually:

lookupPickerField.addValueChangeListener(e -> {
    if (e.getValue() != null) {
        // do some logic
    } else {
        // do some logic
    }
});

It is working… But the value change listener is also called when the screen is loading… I only want the value change listener to be perform some logic when the item is being selected from the lookup window… It should not be called when the screen is loading…

It’s called because data loaded after the init method call. Try to use ready method for adding ValueChangeListener.