Step 1. Create Department Picklist Reusable Part

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.

Prim_DC.iDynamicPicklist

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.

Department Picklist

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

     Name: iiiDepartmentPicklist

     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:

  1. Define component for FindAll in server module iiixDepartmentsDataServer, named FindAll
  1. Execute FindAll passing list xDepartmentsList
  1. RemoveAll entries form PickList
  1. Read all entries in list xDepartmentsList
  1. Add each entry to PickList, passing xDepartmentCode and XDepartmentDescription

     Your code should look like the following:

Mthroutine Name(Load) Options(*REDEFINE)

Define_Com Class(#iiixDepartmentsDataServer.findall) Name(#FindAll)

#FindAll.execute(#xDepartmentsList )

#Picklist.RemoveAll

Selectlist Named(#xDepartmentsList)

#Picklist.add( #xDepartmentCode #xDepartmentDescription )

Endselect

Endroutine 

     Note:

5.  Compile the iiiDepartmentPicklist reusable part.