Set a value based on user input first

I was wondering if there’s a way to to check if the user enter a value in a field and then based on that input set another field automatically in the same table. For example, in Order Entity, there are order type and order_number. The user will choose the type from the list provided and according to the type chosen, a different number will be set automatically to the order_number.

Let me show it on the Customer entity and its name and email attributes.

public class CustomerEdit extends AbstractEditor<Customer> {

    private Datasource<Customer> customerDs;

    public void init(Map<String, Object> params) {
        customerDs.addItemPropertyChangeListener(e -> {
            if (e.getProperty().equals("name")) {
                customerDs.getItem().setEmail(e.getItem().getName() + "");

Now when a user changes customer’s name, its email will be changed too.

Thanks a lot Konstantin, it worked perfectly for me!

I added the following but the studio always shows “can’t find symbol” complie error. Do I need to import any package?

private Datasource<Customer> customerDs;

Hi Thonaslei,

you didn’t show us the compile error in detail so I just can guess.

You probably added that code snippet in the studio and not in the IDE.
For this you need to manage the import statements by your own.

For this given 2 lines of code the import statements are:

import javax.inject.Inject;

… for the entity ‘Customer’ the import should be already exist.


Thank you. It works now.