Override delete method LightAdmin using Listener. Its possible?

202 views Asked by At

I'm using Lightadmin http://lightadmin.org/ crud framework in my Spring MVC project. I was searching the way to override the "delete method" because I want to do a "soft delete" , I have a field in my entities called "deleted". When I press Delete button , really delete the row in my database , I want change that behavior to do a Update , and set the deleted field to true.

I was searching in the official documentation and I found this : http://lightadmin.org/getting-started/registering-repository-event-listeners/ , but when the method on the listener its executed , finally the row is deleted in the database. I would like stop the execution to prevent the delete action. I'm doing a "return" but not working. This is my listener.

Probably the framework LightAdmin was a bad choice, but I need a framework like this. Do you know one?? Thanks to all !!!!!

public class PersonListener extends AbstractRepositoryEventListener<Person> {

private static final Logger logger = LoggerFactory.getLogger(PersonListener.class);


//@Autowired
private PersonFacadeImpl personFacade = new PersonFacadeImpl() ;

//@Autowired
//private PersonFacade personFacade;


@Override
protected void onBeforeDelete(Person entity) {
    //super.onBeforeDelete(entity);
    personFacade.deleteSoft(entity.getId());
    logger.info("ON BEFORE DELETE PERSON " + entity.getName());

    //Here I want prevent the next step , its go to delete the row
    //calling hibernate

    return;

}

@Override
protected void onAfterDelete(Person entity) {
    //super.onAfterDelete(entity);
    logger.info("ON AFTER DELETE PERSON " + entity.getName());

}



}
}
0

There are 0 answers