Alternative to (PersistenceHelper.isNew(getEditedEntity()) in JMIX

Hi
We used the following code to initiate some value when it is a new entity in the Editor screen in CUBA-PLATFORM.

@Subscribe
    public void onAfterShow(AfterShowEvent event) {
        if(PersistenceHelper.isNew(getEditedEntity())){
            ........
        }
    }

I tried to find in the documentation but I didn’t find it easily (in entity events), what is the equivalent in JMIX?

Hi!

You can use the EntityStates bean for the purpose.
Here is an example:

    @Autowired
    private EntityStates entityStates;

    public void test(){
        boolean value = entityStates.isNew(getEditedEntity());
    }

More information about the bean you can find here.

Regards,
Nadezhda.

1 Like

Thank you Nadezhda