Using Zen Mojo
Submitting Data to the Server
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Class Reference   

This chapter describes how to submit data from a Zen Mojo page to the server. It discusses the following:

For an overview, see Submitting Data,” in the first chapter.
Submitting Data to the Server
To enable your page to send data to the server, do the following:
The following shows a simple example for a method that sends a submit object to the server:
ClientMethod myMainViewSelect(key, value) [ Language = javascript ]
    var mainView = zen('mainView');

    switch(key) {
    case 'submitEdits':
        var controlvalue1=mainView.getControlValue('enterName');
        var controlvalue2=mainView.getControlValue('enterCity');
        var submitobject={name:controlvalue1,city:controlvalue2};
        var response = zenPage.submitData('submitEdits',submitobject);
        if (response && response.message) {
The template class defines the %OnSubmitData() method as follows:
ClassMethod %OnSubmitData(pKey As %String, pID As %String, pSubmitObject As %RegisteredObject, 
                          ByRef pResponseObject As %RegisteredObject) As %Status
    Set tSC = $$$OK
    Try {
        if pKey="submitEdits"{
            set id=1
            set tPerson           = ##class(Sample.Person).%OpenId(id)
            set tPerson.Name      =
            set tPerson.Home.City =

            Set pResponseObject = ##class(%ZEN.proxyObject).%New()
            Set tSC = tPerson.%Save()
            If $$$ISERR(tSC) { 
                Set pResponseObject.message = "Your changes were not successfully saved"

            Set pResponseObject.message = "Your changes have been successfully saved"
    Catch(ex) {
        Set tSC = ex.AsStatus()
    Quit tSC