How to use com.vaadin.ui.TextField on cuba-platform?

I want to use com.vaadin.ui.TextField.addFocusListener() method. Who can help me?

package com.company.addondemo.web.customer;

import com.haulmont.cuba.gui.components.*;
import com.company.addondemo.entity.Customer;
import com.vaadin.ui.TextField;
import javax.inject.Inject;
import java.util.Map;

public class CustomerEdit extends AbstractEditor {

@Inject
private HBoxLayout textFieldBox;

private com.vaadin.ui.TextField textField = new TextField();

@Override
public void init(Map<String, Object> params) {
    textFieldBox.add(textField);
    vTextField.addFocusListener(event -> {

    });
}

}

Hi,

You have two options:

  1. Unwrap textFieldBox and add textField to it, e.g.

textFieldBox.unwrap(com.vaadin.ui.Layout.class).addComponent(textField);
  1. Add CUBA TextField component to the desired place on the screen and unwrap it to add FocusListener, e.g.

textField.unwrap(com.vaadin.ui.TextField.class).addFocusListener(event -> {
   // custom code
});

Regards,

Gleb

1 Like

Thank you?