Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Passing a Field or Group of Fields

Passing a List of Data

Passing Returning a Response Object

Anchor
Anch1
Anch1
Passing a Field or Group of Fields

...

The client Web Page or Reusable Part code may be something like this:

     Group_By Name(#MyEmployee) Fields(#xEmployeeIdentification #xEmployeeSurname #xEmployeeGivenNames)
 
Mthroutine Name(UpdateEmployee)

* Define the Server Module routine used to update data on the server
Define_Com Class(#MyServerModule.UpdateEmployee) Name(#UpdateEmp)
     * Update the data asynchronously
#UpdateEmp.ExecuteAsync Status(#io$sts) Employeedetails(#MyEmployee)
 
Evtroutine Handling(#UpdateEmp.Completed)
 
* Insert any processing after completion

Endroutine

Evtroutine Handling(#UpdateEmp.Failed) Handled(#handled)
 
     * Handle failure
 
Endroutine
 
Endroutine

In the Server Module, the corresponding code might be something like this:


     Group_By Name(#Employee) Fields(#xEmployeeIdentification #xEmployeeSurname #xEmployeeGivenNames #xEmployeeStreet #xEmployeeCity #xEmployeeState #xEmployeePostalCode #xEmployeeCountry #xEmployeeHomeTelephone #xEmployeeBusinessTelephone #xEmployeeMobilePhone #xEmployeeSalary #xEmployeeStartDate #xEmployeeTerminationDate #xEmployeeDepartmentCode) 
 
     * Use this group definition to match the details sent from the Web Page
 
     * Group_By Name(#Employee) Fields(#xEmployeeIdentification #xEmployeeSurname #xEmployeeGivenNames)
 
SrvRoutine Name(UpdateEmployee)
Group_Map For(*input) Group(#Employee) Parameter_Name(EmployeeDetails)
Field_Map For(*output) Field(#io$sts) Parameter_Name(Status)
 
Update Fields(#Employee) In_File(xEmployee) With_Key (#xEmployeeIdentification)
 
Endroutine

Anchor
Anch2
Anch2
Passing a List of Data

...

This SRVROUTINE routine returns a list containing all the records in the file.


     Def_List Name(#Employees) Fields(#xEmployeeIdentification #xEmployeeSurname #xEmployeeGivenNames #xEmployeeStreet #xEmployeeCity #xEmployeeState #xEmployeePostalCode #xEmployeeCountry #xEmployeeHomeTelephone #xEmployeeBusinessTelephone #xEmployeeMobilePhone #xEmployeeSalary #xEmployeeStartDate #xEmployeeTerminationDate #xEmployeeDepartmentCode) Type(*working) Entrys(*MAX)  
SrvRoutine Name(GetEmployees)
List_Map For(*Output) List(#Employees)
Select Fields(#Employees) From_File(xEmployee)
Add_Entry To_List(#Employees)
Endselect
Endroutine

There are two ways to receive the list on the Client side, the first is directly into a locally defined list, something like this:


     * Locally defined list
Def_List Name(#EmployeeList) Fields(#xEmployeeIdentification #xEmployeeSurname #xEmployeeGivenNames #xEmployeeStreet #xEmployeeCity #xEmployeeState #xEmployeePostalCode #xEmployeeCountry #xEmployeeHomeTelephone #xEmployeeBusinessTelephone #xEmployeeMobilePhone #xEmployeeSalary #xEmployeeStartDate #xEmployeeTerminationDate #xEmployeeDepartmentCode) Type(*working) Entrys(*MAX)
Mthroutine Name(GetEmployees)
* Define the Server Module method routine
Define_Com Class(#MyServerModule.GetEmployees) Name(#GetEmps)
 
* Return data into locally defined list
#GetEmps.ExecuteAsync( #EmployeeList )
 
Endroutine

Alternately the data could be mapped directly into a data object collection by replacing the DEF_LIST with something like this:


     * Collection of Employee Items that acts as a list
Define_Com Class(#Prim_acol<#MyEmployeeData>) Name(#EmployeeList)

The associated reusable part, MyEmployeeData, would again need to have the corresponding fields included to ensure all the list data is available on the client.


     Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_OBJT *listFields #MyEmployee)

Group_By Name(#MyEmployee) Fields(#xEmployeeIdentification #xEmployeeSurname #xEmployeeGivenNames #xEmployeeStreet #xEmployeeCity #xEmployeeState #xEmployeePostalCode #xEmployeeCountry #xEmployeeHomeTelephone #xEmployeeBusinessTelephone #xEmployeeMobilePhone #xEmployeeSalary #xEmployeeStartDate #xEmployeeTerminationDate #xEmployeeDepartmentCode)

End_Com

Anchor
Anch3
Anch3
Returning a Response Object

A Response Object is typically used to download a file or image from the Application Server.

In this example, an image is read from a database table. The response object is then populated with the image and the file name is set.


SrvRoutine Name(DownloadImage) Response(#Response)
Field_Map For(*Input) Field(#xEmployeeIdentification)
Field_Map For(*output) Field(#io$sts) Parameter_Name(Status)

Fetch Fields(#xEmployeeSurname #xEmployeeGivenNames) From_File(xEmployee) With_Key(#xEmployeeIdentification)  

If_Status Is(*okay)
 
Fetch Fields(#empimg) From_File(xEmployeeImages) With_Key(#xEmployeeIdentification)
 
If_Status Is(*okay)
 
#Response.ContentFile := #Empimg.Filename
#Response.AttachmentFileName := #xEmployeeSurname #xEmployeeGivenNames + (#xEmployeeIdentification  

Endif  

Endif
Endroutine