Skip to main content
Previous section   Next section

Exercises

Complete the Persons application by implementing the following features:
  1. A Delete button on the form. When the user clicks the button, the application deletes the PERSON record that is loaded on the form from the database. In order to implement this feature you must do the following:
    • Implement the %OnDeleteSource method in the MVFILE.PersonModel class. This method uses the %DeleteId class method of the MVFILE.PERSON class to delete the record. Here is the %OnDeleteSource signature:
      
      ClassMethod %OnDeleteSource(pID As %String) As %Status { }             
      
    • Add a JavaScript event-handling function in MVFILE.PersonPage. This function invokes the deleteId of the dataController component. Pass the method the current value of the page's dataController modelId attribute. This value can be retrieved using the dataController getModelId. Finally, the function refreshes the tablePane data.
    • Add a button to the form. The button caption is “Delete”. When clicked it invokes the event-handling function described above.
  2. A New button on the form. When the user clicks the button, the form clears any loaded data. The user then enters data onto the form and clicks Save to create a new MVFILE.PERSON record. In order to implement this feature you must do the following:
    • Implement the %OnNewSource method in MVFILE.PersonModel. This method instantiates a new MVFILE.PERSON object using the MVFILE.PERSON %New class method. Here is the %OnNewSource signature:
      
      Method %OnNewSource(Output pSC As %Status) As %RegisteredObject {}
       
    • Add a JavaScript event-handling function in MVFILE.PersonPage. This function invokes the createNewObject of the page's dataController component.
    • Add a button to the form. The button caption is “New”. When clicked it invokes the event-handling function described above.
Note:
The completed Zen application is in <cachesys>\Dev\tutorials\mv\Zen.xml. For instructions on importing this file into Caché using Studio, read Importing a File Using Studio.
Previous section   Next section