company logo

DBBaseContext :: doBeforeRemove - Before remove handler

The before remove handler is called before removing a data instance from a collection ( DBP_Remove event). The before remove handler can deny removing the data instance by returning an error ( any value >0 ).

Usually, an instance is still selected in the property handle before being removed. In case of maintaining inverse references, however, the instance state is usually located, but not selected. In order to access instance data, the instance in the parent.parent property may be referred to, or the instance has to be read explicitly.

The handler can be overloaded in specialized property context class implementations.

// maintaining inverse persons reference in cars before removing a car from Person::cars

... pCar_persons :: doBeforeRemove () {

  Property        persons(property()); // not selected, but located

  Property        cars(persons.parent());

  

  if ( !persons.selected() )

    persons.get();           // get located instance

  // now do what is necessary

  return(false);

}

Return value:  Execution error ( int32  )

The value is usually returned from context functions or actions in order to report the result of execution. The variable may contain following values:

  • -1: function/action not executed
  • 0: function executed normally
  • 1-9: Function executed with errors. Error codes depend on the function/action called.

Implementation details

int32 DBBaseContext  :: doBeforeRemove (  )