Map Interface
If enabled on any field, the map interface will provide two methods: ToMap and FromMap, which allow the fields enabled within the class to be populated via a map, and the current state of the data is available as a map for saving or processing.
In this example, constants are declared in a separate code module and the views have prefixes that are registered. They are then accessible anywhere in the app.
Constants
'Static code module - Class_Static
Sub Process_Globals
Public Const DATA_HEADER As String = "header"
Public Const DATA_LISTVIEW1 As String = "listview1"
Public Const DATA_FIRSTNAME As String = "firstname"
Public Const DATA_LASTNAME As String = "lastname"
Public Const DATA_INFO As String = "info"
End Sub
Methods
Public Sub ToMap As Map
Dim M as Map
M.Initialize
M.Put(Class_Static.DATA_HEADER, lblHeader.Text)
M.Put(Class_Static.DATA_LISTVIEW1, lvListView1.As(ListView).Items)
M.Put(Class_Static.DATA_FIRSTNAME, tfFirstName.Text)
M.Put(Class_Static.DATA_LASTNAME, tfLastName.Text)
M.Put(Class_Static.DATA_INFO, taInfo.Text)
Return M
End Sub
Public Sub FromMap(M as Map)
lblHeader.Text = M.Getdefault(Class_Static.DATA_HEADER,"Text")
lvListView1.As(ListView).Items.Clear
lvListView1.As(ListView).Items.AddAll(M.Getdefault(Class_Static.DATA_LISTVIEW1,NewList))
tfFirstName.Text = M.Getdefault(Class_Static.DATA_FIRSTNAME,"")
tfLastName.Text = M.Getdefault(Class_Static.DATA_LASTNAME,"")
taInfo.Text = M.Getdefault(Class_Static.DATA_INFO,"")
End Sub
This makes accessing data related to a layout straightforward.