Create listeners

Good day,

I have been using the earlier version of cuba 6.10 and recently started using 7.2.
I am trying to auto generate a unique value, using UniqueNumbersAPI.
In cuba 6.10 I would implement this in a beforeCreateEntityListener.

How can I implement this in 7.2? I cannot find a beforeCreateEntityListener in the studio to implement this.

Thank you in advance.

You can just create a listeners bean and put it here
image
A template example of a bean of entity listeners is in the documentation.

Apologies @andreyvb

I created a bean and named it listener.
rrrr

it opened up the above screen.

Questions
Do I have to manually specify this listeners or there is a way of just injecting them into the code.
Please provide me with an example as well.

Thank you in advance

Studio 14 no longer has the ability to generate Entity listeners automatically.
To replace Entity listeners there is a new mechanism - EntityPersistingEvent and EntityChangedEvent.

An example of Entity listeners bean is available on this documentation page.

package com.company.sample.listener;

import com.company.sample.entity.*;
import com.haulmont.cuba.core.listener.*;

@Component("sample_OrderEntityListener")
public class OrderEntityListener implements
        BeforeInsertEntityListener<Order>,
        BeforeUpdateEntityListener<Order>,
        BeforeDeleteEntityListener<Order> {

    @Override
    public void onBeforeInsert(Order entity, EntityManager entityManager) {
        //....
    }

    @Override
    public void onBeforeUpdate(Order entity, EntityManager entityManager) {
        //...
    }
...
...
}

Hi,
The ability to generate entity listeners was intentionally removed from the Studio UI, though you can create them manually in the code.
For most users it’s recommended to use EntityPersistingEvent and EntityChangedEvent, like Andrey commented.
New entity events are easier to use for most developers because of more predictable behavior.
The suitable event for your situation is EntityPersistingEvent. Its listener bean can be generated using Studio, see CUBA Studio User Guide

Thank you @AlexBudarov
This was very helpful.