public class InvoicesEdit extends AbstractEditor<Invoices> {
@Inject
private UniqueNumbersService uniqueNumbersService;
@java.lang.Override
protected void initNewItem(Invoices item) {
super.initNewItem(item);
item.setRegistrationNo(uniqueNumbersService.getNextNumber("Domain1"));
}
}
I created a new datasource - registrationNoDs but I’m not sure if I need to create a new view too.
However I have three datasources: datasource:invoicesDs, collectionDatasource:ordersDs and datasource:registrationNoDs.
Unfortunately when I press button Edit I have the following error message:
java.lang.ClassCastException: com.haulmont.cuba.gui.data.impl.DatasourceImpl cannot be cast to com.haulmont.cuba.gui.data.CollectionDatasource
The problem is not related to the code you attached. Please check your datasource injection points, there is an incorrect type of datasource in one of them.
It works. The RegistrationNo mandatory option should be unchecked.
The text field RegistrationNo is completed automatically after Save.
However there is a way to see the generated number before Save?