WAM080 - Session Management
1. Define a working list EMPDATA for employee details:
Def_List Name(#empdata) Fields(#EMPNO #SURNAME #GIVENAME #ADDRESS1 #ADDRESS2 #ADDRESS3 #POSTCODE #PHONEHME #PHONEBUS #DEPTMENT #SECTION #SALARY #STARTDTE #TERMDATE) Counter(#listcount) Type(*Working) Entrys(1)
2. Define a group by to display employee fields
Group_By Name(#empgrp) Fields((#EMPNO *out) (#SURNAME *out) (#GIVENAME *out) (#ADDRESS1 *out) (#ADDRESS2 *out) (#ADDRESS3 *out) (#postcode *out) (#PHONEbus *out) (#phonehme *out) (#DEPTMENT *out) (#SECTION *out) (#SALARY *out) (#STARTDTE *out) (#TERMDATE *out))
3. Extend the web_map for persistent data to include list EMPDATA.
Web_Map For(*none) Fields(#empsave #empdata) Options(*PERSIST)
4. Extend case loop in the search WebRoutine to clear the saved lists.
When (= C)
Message Msgtxt('Saved employee list was cleared')
5. Extend the case loop in the showsave WebRoutine to fetch employee data and add an entry to the list EMPDATA.
When (= D)
Fetch Fields(#empgrp) From_File(pslmst) With_Key(#empno) Val_Error(*next)
Message Msgtxt('Employee details saved')
6. In the showsave WebRoutine, add a web_map for input for field EMPNO. This value will be passed in for the selected row, by the clickable image.
Web_Map For(*input) Fields(#empno)
7. Create a new WebRoutine showemp to retrieve the one entry from the list EMPDATA or transfer to the search WebRoutine.
WebRoutine Name(showemp) Desc('Show Saved Employee')
Web_Map For(*output) Fields(#empgrp)
If (#listcount = 1)
Get_Entry Number(1) From_List(#empdata)
Message Msgtxt('Employee details not available')
8. Compile your WAM.
9. Open the search WebRoutine in the Design view.
10. Add a push button into the table at the bottom of the page. Set up the button properties:
11. Add a third push button into the table at the bottom of the page and setup the button properties:
12. Remove the place holder characters from this table.
13. Save your changes.
14. Open the showsave WebRoutine in the Design view.
15. Select and delete the column heading for the first column.
16. Drop a clickable image into the first column (field STDSELECT). Set up the clickable image properties:
17. Save your changes.
18. Open the showemp WebRoutine in the Design view. Drop a push button onto the page below the list. Set up the button properties:
19. Save your changes.
20. Test your WAM.
a. You should now get the following results:
b. Start your WAM from any WebRoutine except WebRoutine init. You should be transferred to the init WebRoutine to establish a session, and then transferred to the search WebRoutine, displaying suitable messages.
21. In your WAM source, use F7 to display WAM properties on the Details tab. Change the Session Timeout from its default value (300 seconds) to 10 and recompile your WAM.
22. Test your WAM.
Perform a search and display the saved list. This should be displayed. However, due to the very short time out (10 seconds) by the time you return to the search web page, the WAM will have timed out, giving appropriate messages. If you then immediately display the saved employee list, there will be no entries.
Note: The session timeout value is the "wait time" for the response from the client (the browser). So with a session timeout of 10 seconds, whenever you delay for more than 10 seconds, the session will time out. If on the other hand you keep sending requests to the server within the 10 second time out window, the session will never time out.
Persistent data will only be retrieved if the session is active. If a new session is established, due to time out, there is currently no persistent data for that session.