25.01.2015 Views

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Using</strong> Callback Methods<br />

ReturnValue<br />

Insert<br />

A %Status code, where returning a failure status from %OnAfterSave<br />

causes %Save to fail and ultimately roll back the transaction.<br />

A flag indicating if the object being saved is being inserted into the<br />

extent (1) or that it is already part of the extent (0).<br />

This method is available to the %Library.Persistent class and its subclasses.<br />

20.3 %OnBeforeSave<br />

This instance method is called by the %Save method just before an object is saved. This<br />

method allows you to request user confirmation before completing an action and can also<br />

serve to ensure the validity of an instance's data and relationships prior to saving the instance<br />

to disk.<br />

Its syntax is:<br />

ReturnValue %OnBeforeSave(Insert as Boolean)<br />

where:<br />

ReturnValue<br />

Insert<br />

A %Status code, where an error code causes the save to fail.<br />

A flag indicating if the object being saved is being inserted into the<br />

extent (1) or that it is already part of the extent (0).<br />

This method is available to the %Library.Persistent class and its subclasses.<br />

20.4 %OnClose<br />

This instance method is called by the %Close method just before an object is closed. One<br />

use of this method is to release resources that <strong>Caché</strong> does not directly control, but are logically<br />

related to the application, such when an object represents a communication device and closing<br />

the object invokes the %OnClose code to drop the connection.<br />

172 <strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!