How can i get value from selected row in screeen table?

I have simple function in screen controler which generates buttons in Table B via table generator.
I need to pass Table A item it the funcion. How to achieve this?

Screenshot_25

<column id="phoneNumber" generator="createCallButton" caption="msg://TelefonneCislo"/>

Example of code:

public Component createCallButton(UserPhone userPhone) {
    if(userPhone.getPhoneNumber() != null){
        String url = "tel:" + userPhone.getPhoneNumber();

        Button btn = uiComponents.create(Button.class);
        btn.setCaption(userPhone.getPhoneNumber());
        btn.setIcon("font-icon:PHONE");
        btn.addClickListener(clickEvent -> {
            try {
                Desktop desktop = java.awt.Desktop.getDesktop();
                URI uri = new URI(url);
                desktop.browse(uri);
                
                Hovory newHovor = dataManager.create(Hovory.class);
                newHovor.setTelefon(userPhone.getPhoneNumber());
                newHovor.setStav("nove");
                newHovor.setTrvanie(0.0);
                
                newHovor.setNavrhyplatby(); //i need to pass value here so the record will be  related to Table A
                dataManager.commit(newHovor);

            } catch(IOException | URISyntaxException e) {
                LOG.warn(e.getMessage());
            }
        });
        return btn;
    } return null;
}

Just @Inject the table, and use tableA.getSingleSelected().getWhatever() to access the value you need (that is if I understand your question correctly).

Inject not applicable in local variable.

If this code is in a screen controller, as you said it was, then you can Inject any components which are on the screen the controller controls…

I must have been blind. Thank you!

You’re welcome, Igor. :slight_smile: