Step 4. Make Application WAMs part of Session

In this step you will enable session management in WAM iiiEmpEnquiry and make it share the session group IIISESSION. The WAM will need to map the saved and output menu lists in the same way as already implemented in the log in WAM iiiAppLogin.

1.  Open WAM iiiEmpEnquiry in the editor. Press F7 to display the WAM properties and make SessionStatus active and SessionGroupName, IIISESSION.

2.  Copy and paste the following field, list and web_maps statements from iiiAppLogin. In a real application the menu fields would be defined in the Repository.

Define Field(#mnuitmid) Type(*string) Length(3)
Define Field(#prtitmid) Type(*string) Length(3)
Define Field(#mnucapt) Type(*char) Length(30) Input_Atr(LC)
Define Field(#mnuurl) Type(*string) Length(256)
Define Field(#mnuwam) Type(*char) Length(9)
Define Field(#mnuwrnme) Type(*char) Length(30)
Def_List Name(#mnusave) Fields(#mnuitmid #prtitmid #mnucapt #mnuurl #mnuwam #mnuwrnme) Type(*Working)
Def_List Name(#mnulist) Fields(#mnuitmid #prtitmid #mnucapt #mnuurl #mnuwam #mnuwrnme) Type(*Working)
Web_Map For(*output) Fields((#mnulist *private))
Web_Map For(*none) Fields(#mnusave) Options(*persist)


3.  Add an event handling routine for SessionInvalid. This will transfer to WAM iiiAppLogin and WebRoutine login if any WebRoutine is invoked without a session being established or after a session has timed out. Change iii to your initials.

TRANSFER TOROUTINE(#iiiAppLogin.login)


4.  Change the initial WebRoutine in iiiEmpEnquiry, in this case it is WebRoutine begin, to clear list MNULIST and populate it from MNUSAVE. Your WebRoutine begin code should now look like the following. Changes are shown in red.

Webroutine Name(begin) Desc('Select Employee')
Web_Map For(*output) Fields(#empno)
Clr_List Named(#mnulist)
Selectlist Named(#mnusave)

Add_Entry To_List(#mnulist)



     Remember list MNUSAVE is automatically restored when the WAM runs, because session management is active and the list is mapped as persistent data. Both field values and lists may be defined as persistent data.

5.  Compile iiiEmpEnquiry.