docs.intersystems.com
MultiValue Quick Start Tutorial
Creating the Model Class: Methods
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Search:    

The model must implement a set of callback methods that can be invoked by a dataController component. These methods allow the dataController to create, retrieve, update, and delete data from the data sources associated with the model.

Add the following methods to MVFILE.PersonModel.cls. These methods allow the dataController to open and save existing MVFILE.PERSON objects.
  1. Method %OnOpenSource(pID As %String, pConcurrency As %Integer = -1, 
    Output pSC As %Status) As %RegisteredObject
    { 
    Return "MVFILE.PERSON"->%OpenId(pID,pConcurrency,pSC)
    }   
    
    The dataController invokes this method to open an existing MVFILE.PERSON object.
  2. Method %OnSaveSource(pSource As MVFILE.PERSON) As %Status
    {
    tSC = pSource->%Save()
    IF ("%SYSTEM.Status"->IsOK(tSC))THEN  
     @ME->%id = pSource->%Id()
    END
    Return tSC
    }
    
    The dataController invokes this method when saving updates to an MVFILE.PERSON object.
Note:
The exercises at the end of this part of the tutorial describe how to implement callback methods that support creating and deleting MVFILE.PERSON objects.


Send us comments on this page
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA