Lookupfiled value change listner in cuba version 7.0.9

I migrated my project in Cuba 6.10 to Cuba 7.0.9, after migration my lookup field value change listener is not working? How I get the selected value from the lookup field in Cuba 7.?


If something doesn’t work, please be more specific about what’s broken.


In Cuba version 6.10 i used the following code to get the selected object from a lookup field

     private LookupPickerField studentName;
     public init(Map String, Object params)

        studentName.addValueChangeListener(new ValueChangeListener(){
                         void valueChanged(ValueChangeEvent e){
                          Student student= (Student)e.getValue();
                          String slectedStudent=student.getName();      

but when migrated to Cuba version 7 this code is not working and showing the ValueChangeListener, ValueChangeEvent, etc are not available. Is there any new way to get the selected option from the optionlist(lookupfield) in Cuba 7?

All addSomeListener and removeSomeListener methods in UI components now receive Consumer<E> where E is a type of event object, so you need to define a type when injecting a component, e.g.

private LookupPickerField<String> studentName;

Alternatively, you can remove previous code and inject a component again using the injection menu.

You can find the complete list of breaking changes here.

Also, we have migration guides:
Migration to CUBA 7 API: Screens
Migration to CUBA 7 API: Browser / Lookup Screens
Migration to CUBA 7 API: Editor Screens
Migration to CUBA 7 API: Required Components Migration
Migration to CUBA 7 API: Optional Components Migration

1 Like

Thanks @gorelov