如何在标准编辑界面中的onBeforeCommitChanges事件里判断是新增还是修改

如何在标准编辑界面中的onBeforeCommitChanges事件里判断实体当前是新增还是修改呢?

看 PersistenceHelper.isNew 可以用吗

可以的,感谢!:+1:

目前还有这个吗?

这是Jmix版:界面事件 :: Jmix 文档

请问Jmix如何判断?

EntityStates bean。Jmix项目自带了一个 UserEdit.java,里面有用法:

    @Subscribe
    protected void onBeforeCommit(BeforeCommitChangesEvent event) {
        if (entityStates.isNew(getEditedEntity())) {
            if (!Objects.equals(passwordField.getValue(), confirmPasswordField.getValue())) {
                notifications.create(Notifications.NotificationType.WARNING)
                        .withCaption(messageBundle.getMessage("passwordsDoNotMatch"))
                        .show();
                event.preventCommit();
            }
            getEditedEntity().setPassword(passwordEncoder.encode(passwordField.getValue()));
        }
    }