Step 3 Change Employee Details Command Handler

VLF Windows Application Development

Step 3. Change Employee Details Command Handler

VFW122 – Launching a VLF Window

In this step you will change the Employee Details command handler, iiiVFW06 to handle the avShowWindow method.

If a filter or command handler is either started, or already active inside window EMP_WINDOW, then if it has the special 'wake up' method in it, the method will be invoked every time some other window executes:

Mthroutine uShowWindowCompleted Options(*Redefine)
#Empno := #Com_Owner.avCurrentWindow.OpenInfo<1>
Use message_box_show (ok ok info *Component #Empno) 
Endroutine

 

this method will be invoked every time some other window executes:

#AvFrameworkManager.avShowWindow WindowName(EMP_WINDOW)

 

In other words, this is a method that is saying 'wake up, another window wants you to do something'. Typically the command handler or filter that is 'woken up' would use information passed in the open information strings to determine what it should do next.

1.   Open the Employee Details command handler (iiiVFW06)  in the editor.

2.  Add the following logic to create the uShowWindowCompleted method routine:

Mthroutine Name(uShowWindowCompleted) Options(*Redefine)
#EMPNO := #Com_Owner.avCurrentWindow.OpenInfo<1>
Fetch Fields(#XG_HEAD) From_File(PSLMST) With_Key(#EMPNO) Val_Error(*next)
If_Status Is_Not(*okay)
Message Msgtxt('Employee Details not found for : ' + #EMPNO)
Endif
#fullname := #SURNAME + ', ' + #GIVENAME
#com_ancestor.avSignalEvent Withid(Add_List_Entry) Sendainfo1(#EMPNO)
#DEPSEC_DD.ucurrDept := #deptment
#DEPSEC_DD.uCurrsection := #section
Endroutine

 

     Note:

  • DEPSEC_DD is the department / section dropdown component (iiiVFW14) which was added in exercise VFW074.

3.  Review the code in Step 2 and note that:

  • Employee number is retrieved using #Com_owner.uCurrentWindow.OpenInfo<1> which was set up by the avShowWindow in the Employee Images for Section command handler.
  • Required fields are retrieved from the employee file.
  • An avSignalEvent is used, to tell the active filter to add an entry to the instance list.

4.  Compile the changed Employee details command handler – IIIVFW06.

5.  Execute your framework and display the Images command handler for a suitable Department / Section (in which one or more employees have images recorded).

6.  Display the pop-up menu for an employee image and select the Open Employee Details Window option. A second framework window should be opened.

     Notice that employee details are not displayed for the first employee requested.

7.  Select another employee image and select Open Employee Details Window again from the conext menu. This time, notice that in the new window an entry is added to the instance list and the correct employee details are displayed.

     Do you know why this is happening?