Step 5. Add Save Logic to the Web Page

In this step you will add logic to your web page to call the Save srvroutine in the xEmployee server module.

1.  Copy the Group_By definition xEmployee in the server module and paste it into your web page, at the top of the code, following the Define_Com statements..

2.  Create a method routine with the name Save. Give the method routine a keyword of Access(*private). The routine will only be invoked from within this web page.

3.  Within the Save method routine, define your Server Module as a component with the Name SaveEmployee

     Your code should look like the following:

Mthroutine Name(Save) Access(*private)

Define_Com Class(#iiixEmployeeDataServer.Save) Name(#SaveEmployee)



4.  The following steps will add code to invoke the srvroutine, which will run on the server.

     Add the following code, which invokes the SaveEmployee srvroutine in the Server Module asynchronously, passing the Group_By xEmployee and receiving the output IO$STS field.

#SaveEmployee.executeasync( #xEmployee #IO$STS )


     Note: The fields and Group_By parameters must be specified within the executeasync() in the same sequence they are defined on the web_map statements in the Server Module srvroutine.

     Alternatively specify the fields using parameter names:

#SaveEmployee.executeasync Xemployee(#xEmployee) Status(#IO$STS)


5.  As the Server Module srvroutine is being executed asynchronously, to execute logic when the srvroutine has completed, you should add an event routine for the srvroutine's Completed event.

     Add the following event routine within your Save method routine.

Evtroutine Handling(#SaveEmployee.Completed)



6.  Within the Completed event routine, check the returned IO$STS field for a value OK and clear all the employee fields. Your code should look like the following:

Evtroutine Handling(#SaveEmployee.Completed)

If (#io$sts = OK)

#xEmployee := *null




7.  Complete the SAVE push button click event by adding logic to execute the Save method routine.

     Your code should look like the following:

Evtroutine Handling(#SAVE.Click)