LookupField Multi-Property CaptionProperty

I know that the LookupField has the setCaptionProperty method, but I think it would be useful to specify a caption pattern, similar to an Entity’s Instance Name, where multiple properties can be specified. Like a local instance name for the Field.

Hi,

Since version 7.0 you will be able to set a lambda expression that generates option caption.

It can be done using new @Install annotation:

public class NewScreen extends Screen {    
    @Install(to = "userLookupField", subject = "optionCaptionProvider")
    protected String getUserCaption(User user) {
        return String.format("%s - %s", user.getLogin(), user.getName());
    }
}

Or programmatically:

@Inject
protected LookupField<User> userLookupField;

@Subscribe
protected void onInit(InitEvent event) {
    userLookupField.setOptionCaptionProvider(user -> 
            String.format("%s - %s", user.getLogin(), user.getName())
    );
}