Step 3. Filter Code

Even though you can create most filters simply by using the Program Coding Assistant, you should understand how they are coded.

1.   Switch to the Visual LANSA editor where the iiiCOM01 component is open.

2.   Review the generated source code in the Source tab to see how the filter is coded to add data to the instance list: 

The Framework is notified that an update is about to occur.

Invoke #avListManager.BeginListUpdate

 

Next, the list is cleared of any existing items.

Invoke #avListManager.ClearList

Next, data is selected. You can use one the techniques you learnt in the Visual LANSA Fundamentals tutorials to do this. For example:

Select Fields(#XG_Ident) From_File(xEmployeeBySurname) With_Key(#XG_Keys) Nbr_Keys(*Compute) Generic(*yes)

 

Next, the visual identifiers are set up:

#UF_VISID1u := #xEmployeeIdentification

#UF_VISID2u := #xEmployeeSurname

 

Then the data is added to the list.

#avListManager.AddtoList Visualid1(#UF_VISID1u) Visualid2(#UF_VISID2u) Akey1(#xEmployeeIdentification) Acolumn1(#xEmployeeGivenNames)

VisualId1 will be shown in column one of the instance list and VisualId2 will be shown in column two of the instance list.  Akey1 is the key that uniquely identifies an employee (in this case the field is alphanumeric, so it's Akey1, not Nkey1).

 

Finally, the Framework is notified that the instance list update is complete.

Invoke #avListManager.EndListUpdate)

 

3.  Next click on the Details tab in the editor to display the properties of your component.

4.   Notice that the Ancestor property of the component is #VF_AC007. All filters inherit from this base class which provides a set of predefined behavior.

5.   Click on the Outline tab in the editor to see what components you inherit from the VF_AC007 ancestor component.

6.   Right-click the avLISTMANAGER component and select the Features option.

 

7.   Expand the methods of the component and examine them.

When you move your mouse over the methods, their description is displayed in a hint. Note that you cannot display online help for Framework properties/methods/events by double-clicking them as you can with Visual LANSA properties/methods/events.

If you cannot see the hints, display the Options in the Visual LANSA editor and select the Show Hints option.

8.   Close the iiiCOM01 component.

You may want to read Filter and Command Handler Anatomy to see how these components are structured.