Step 5 Complete the Image Command Handler

VLF Windows Application Development

Step 5. Complete the Image Command Handler

VFW080 – Using an Explorer Component

1.  In the Design view, drag and drop your Find Employee Image form (iiiVFW15) onto the Employee Image CH reusable part (iiiVFW16).

     This will create a Define_Com for iiiVFRW15. Select the Source tab and change the Name of iiiVFW15 to Find_Image:

Define_Com Class(#IIIVFW15) Name(#Find_Image) Componentversion(2)

 

2.  An Instance List command handler is invoked by the Framework, when an entry is selected in the business object Instance list and its uExecute method is invoked.

     Create the uExecute method routine. This must redefine the method which is already defined in the ancestor VF_AC010. It should invoke the uExecute method in the ancestor.

     Your code should look like the following:

Mthroutine Name(uExecute) Options(*redefine)
#com_ancestor.uExecute
Endroutine

 

3.  Your uExecute logic, needs to do the following:

a.  Get the employee number for the current instance list entry

b.  Fetch the employee image field (iiiEmpImg) from file iiiEmpImages

c.  Set the image component filename property from the retrieved employee image

d.  Handle a not found error, when the employee has no image.

Your new code should look like the following:

#avlistmanager.getCurrentInstance Akey1(#empno)
Fetch Fields(#iiiempimg) From_File(iiiEmpImages) With_Key(#empno) Val_Error(*next)
If_Status Is(*okay)
#IMGE_1.fileName := #iiiempimg.fileName
Else
#IMGE_1.fileName := *null
#IMGE_1.updateDisplay
Endif

 

4.  The Find button Click event, simply needs to invoke the Find Employee image form, as a modal form.

     Your completed Find button Click event should look like the following:

Evtroutine Handling(#PHBN_FIND.Click)
#Find_Image.ShowModalForm
Endroutine

 

5.  When an image is selected in the Find Employee Image form, the user will click the OK button. This will signal the uImageSelected event, passing the image path and filename.

     In the Employee Image command handler, add an event handling routine, which sets the image filename (IMGE_1.filename).

     Your code should look like the following:

Evtroutine Handling(#Find_Image.uImageSelected) Ufilename(#FileName)
#IMGE_1.fileName := #FileName
Endroutine
 

6.  The Save button Click routine, needs to do the following:

a.  Set the field value for iiiEmpImg to the image filename property

b.  check for an existing entry in file iiiEmpImages

c.  Update or Insert to the file iiiEmpImages as appropriate.

Your code should look like the following:

Evtroutine Handling(#PHBN_SAVE.Click)
#iiiempimg := #IMGE_1.fileName
Check_For In_File(iiiEmpImages) With_Key(#empno) Val_Error(*next)
If_Status Is(*equalkey)
Update Fields(#iiiempimg) In_File(iiiEmpImages) With_Key(#empno)
Else
Insert Fields(#empno #iiiempimg) To_File(iiiEmpImages)
Endif
Endroutine

 

7.  Compile your command handler iiiVFW16.