Visual Hosts and Dynamic Picklists
A Visual Host allows you to define a reusable part to act as the edit portion of a field. This allows you all the flexibility of a reusable part while still taking advantage of LANSA Repository features for multilingual descriptions, labels and column headings.
Dynamic Picklists allow you to define the items in a picklist at runtime, usually by loading them from a table.
Implementing iDynamicPicklist allows a visualization reusable to load the picklist at runtime.
Load – The load method is executed during initialization and any time a monitored value or context changes. This picklist instance is received via the Picklist map.Define_Map For(*input) Class(#PRIM_PKLT) Name(#Picklist) Pass(*BY_REFERENCE)
The instance of the picklist is maintained at runtime meaning that the user must clear the list, if new data is required.
In this example the Load method will load the picklist from the Departments table, xDepartments.
Since you are building a dynamic picklist for a web page application, the reusable part must retrieve department data by executing the iiixDepartmentsDataServer server module's FindAll srvroutine.
1. Create a New / Reusable Part /Object
Description: Department Visual Picklist
Target Platform: Web Browser
2. Change the Begin_Com Role() to implement a dynamic picklist:
Begin_Com Role(*EXTENDS #PRIM_OBJT *implements #Prim_dc.iDynamicPicklist)
3. Copy and paste the working list xDepartmentsList from the iiixDepartmentsDataServer server module at the top of the reusable part source.
4. Define a Load routine to redefine the ancestor Load routine, based on the following:
Your code should look like the following:
Mthroutine Name(Load) Options(*REDEFINE)
Define_Com Class(#iiixDepartmentsDataServer.findall) Name(#FindAll)
#Picklist.add( #xDepartmentCode #xDepartmentDescription )
5. Compile the iiiDepartmentPicklist reusable part.