Lookup Field choose particular values


I have a One-to-One relation between two entities and I use a Lookup Field in order to select the appropriate rows. The problem is that I have an enumeration field and the user should can choose only particular values (see below).

        <![CDATA[select e from abc_Customer e where e.test = 'A' ]]>

This works for the first button (arrow) but if I press “Open a lookup screen button” the user can see whole table.

Please advise!


To be more precisely it’s about a LookupPickerField and lookup action.

Hello @neutrino,

To solve your problem you need to take two steps:

  1. Override the default picker_lookup action behavior to pass a specific parameter “testValue” to CustomerBrowse screen. You can find an example of use in the documentation
    private ScreenBuilders screenBuilders;
    private LookupPickerField<Customer> customerField;

    public void onCustomerFieldLookup(Action.ActionPerformedEvent event) {
        screenBuilders.lookup(Customer.class, this)
                .withOptions(new MapScreenOptions(
                        ParamsMap.of("testValue", "A")))
  1. Delegate data loading to customersDlLoadDelegate function in CustomerBrowse. If the “testValue” parameter is passed, then it is taken into account when loading data. You can find an example of use in the documentation
public class CustomerBrowse extends StandardLookup<Customer> {

    private String testValue;

    private DataManager dataManager;

    @Install(to = "customersDl", target = Target.DATA_LOADER)
    private List<Customer> customersDlLoadDelegate(LoadContext<Customer> loadContext) {
        if (testValue != null) {
            loadContext = loadContext.setQuery(
                    LoadContext.createQuery("select e from abc_Customer e where e.test = :testValue")
                            .setParameter("testValue", testValue));
        return dataManager.loadList(loadContext);


1 Like

Gleb you are the best!
Thank you!

Can you explain a little bit when should I use Install Delegate?
This chapter is kind of “twilight zone” for me.

Best Regards,

Hi @neutrino,

Using delegates, you can provide code that will be used by various screen mechanisms instead of their standard implementations. For example, you can provide your own function to load data or to set the row icon provider for the table and much more.
You can see the entire list of delegates for the screen controller in the Install Delegate tab using the CUBA Studio.


Each delegate in the window is provided with a description on the right which is extracted from the framework Javadocs.


1 Like