Beginners question: Do some action after select a lookuptable

Hi,

I am an absolute beginner in cuba and just playing around with the workshop app.
I did not find a way, to fill in something from the “Client” (for example the “name”)
into the field “Description” of the “Order”-mask.

I searched for a kind of event, that happens after the Button “Select” is klicked in
the client-browser-list, which is closing the client-browser and returns to the order-Mask.

The reason for the question is to copy some informations from a lookup-datarecord to
the editmask.

I am sure, its not a complex problem, but I don’t find a way.

Maybe someone can show me a way.

Thanks

Hi,

I thank you should override one of the lookup action methods, like afterSelect() or afterCloseLookup() as described in the docs: [url=]https://doc.cuba-platform.com/manual-6.4/picker_actions.html[/url]

You can also do it without extending the action class and overriding methods. Use setAfterLookupSelectionHandler() method to add a lambda expression that will be executed after selection:

@Named("fieldGroup.myField")
private PickerField myField;

@Override
public void init(Map<String, Object> params) {
    myField.getLookupAction().setAfterLookupSelectionHandler(items -> {
        doSomethingWithSelectedItems(items);
    });
}

Thanks,

i will try.

Hi,

Thanks for your answer. I tried to find out what you mean, but i couldn’t get it.
Can you tell me, i which class-file i have to do this ?
I tried in the OrderEdit.java, but it did not work.

There was a nullpointer exception.

I dont find a way.

Yes you should do it in the Order editor. Make sure you name the field in the @Named annotation correctly.

Hi,
Thanks, i got one step more … but the next:

package com.pd.abf.web.auftragkopf;

import com.haulmont.cuba.core.entity.Entity;
import com.haulmont.cuba.gui.WindowManager;
import com.haulmont.cuba.gui.components.*;
import com.pd.abf.entity.Adresse;
import com.pd.abf.entity.AuftragKopf;

import javax.inject.Inject;
import javax.inject.Named;
import java.util.Map;

public class AuftragKopfEdit extends AbstractEditor<AuftragKopf> {

    @Named("fieldGroup.myKunde")
    private PickerField myKunde;


    @Override
    public void init(Map<String, Object> params) {
        super.init(params);

        myKunde.getLookupAction().setAfterLookupSelectionHandler(items -> {


            if (items != null) {
                for (Object i : items) {
                    if (i != null) {
                        Adresse a = (Adresse) i;

                        this.showMessageDialog(
                                "ok it works: ",
                                " Adress: "+a.getName1()+ " selected !",MessageType.CONFIRMATION_HTML);

                    }
                }
            }

        });
    }
}

brings me the picked adresse which was selected. Now I need to get access to the other fields (textfields) of the Order-Mask.

Do you you have some books or videos to buy to get more information about this ?

Thanks

You should inject the fields to the controller class.

As for learning materials, I would suggest going through quick start and Full-scale CUBA application: Step by Step Guide.

OK.
I try. Thanks for your help.