Step 4. Add Fetch Logic to the Web Page

In order to check your added records, we will include add fetch logic in the application.

1.  Create a method routine with the Name Find. It should be invoked from within the web page only.

2.  The Find routine should perform the following:  

Define your xEmployee server module's Find srvroutine as a component, named GetEmployee.

Execute GetEmployee, asynchronously, exchanging field xEmployeeIdentification, Group_By xEmployee and field IO$STS.

Include a GetEmployee.Completed event routine.

     The GetEmployee.Completed event will be needed in a later exercise. For now, no code is needed in this routine as the web page fields will be populated as soon as the Find srvroutine completes.

     Your code should look like the following:

Mthroutine Name(Find) Access(*private)

Define_Com Class(#iiixEmployeeDataServer.find) Name(#GetEmployee)

#GetEmployee.executeasync( #xEmployeeIdentification #xEmployee #IO$STS )

Evtroutine Handling(#GetEmployee.Completed)

Endroutine

Endroutine 

     Note: You may not always need to include a Completed event routine, as in this Find routine.If the routine is simply fetching a record, when the data is returned, the fields are displayed on the web page immediately. This will signal to the user to carry on. Of course, you may need to include error handling, if a record is not found.

     A Completed event routine could be used to enable the Save push button which was initially set to Enabled(False). For now, we will keep this training example simple.

3. Complete the Fetch.Click event by adding code to invoke the Find method.

     Your code should look like the following:

Evtroutine Handling(#FETCH.Click)

#com_self.Find

Endroutine

 

4.  Complete the push button CLEAR.Click event, by adding code to clear the fields in Group_By xEmployee.

     Your code should look like the following:

Evtroutine Handling(#CLEAR.Click)

#xemployee := *null

Endroutine

5. Compile your web page.