Dropdown list for entity editor string value

I have an entity say Apples.class

And apples has a field String Color

Is it possible, when using the generic editor, to have a dropdown list of colors that are generated from a database query?

e.g. instead of typing in color:Blue, have it be a dropdown list which is populated on init() with the various colors like it does for an enum. Basically I just want what it does for enums but with the separate values populated from a database query.


This is possible, have a look here:


Or if it is expressable via jpql then take a look at this example: https://demo.cuba-platform.com/sampler/open?screen=related-entity-lookupfield

Hi Mario,

But how do I change it to a look up field in the standard entity editor?lookup


in the FieldGroup it is a little different.

I attached you an example application.

The example is Customer entity with “preferredColor” attribute which is a String and should be selectable. The CustomerEdit code looks like this:

public class CustomerEdit extends AbstractEditor<Customer> {

protected FieldGroup fieldGroup;

protected ComponentsFactory componentsFactory;

protected Datasource<Customer> customerDs;

private final String PREFERRED_COLOR_ATTRIBUTE_NAME = "preferredColor";

public void init(Map<String, Object> params) {

private void initPreferredColorLookupField() {

    LookupField preferredColorLookupField = createLookupFieldComponent();

    preferredColorLookupField.setDatasource(customerDs, PREFERRED_COLOR_ATTRIBUTE_NAME);

private void setLookupFieldToFieldGroup(LookupField preferredColorLookupField) {
    FieldGroup.FieldConfig preferredColorField = fieldGroup.getField(PREFERRED_COLOR_ATTRIBUTE_NAME);

private LookupField createLookupFieldComponent() {
    return (LookupField) componentsFactory.createComponent(LookupField.NAME);

private Map<String, String> createPreferredColorOptions() {
    Map<String, String> preferredColorOptions = new HashMap<>();
    preferredColorOptions.put("Green", "Green");
    preferredColorOptions.put("Blue", "Blue");
    preferredColorOptions.put("Yellow", "Yellow");
    preferredColorOptions.put("Red", "Red");
    return preferredColorOptions;

cuba-example-fieldgroup-custom-dropdown.zip (93.3 KB)

I hope this example helps you.