
* list of employees to be saved on the server
Def_List Name(#empsave) Fields(#empno #surname #givename) Counter(#std_count) Type(*Working) Entrys(99)
* latest search list of employees
Def_List Name(#empnew) Fields((#empno *out) (#surname *out) (#givename *out)) Type(*Working) Entrys(99)
* display current saved list of employees.
Def_List Name(#empdisp) Fields(#stdselect (#empno *out) (#surname *out) (#givename *out)) Type(*Working) Entrys(99)
* Map persistent data
Web_Map For(*none) Fields(#empsave) Options(*PERSIST)
* Map common return field from weblets
Web_Map For(*input) Fields((#stdrentry *hidden))
* Initialize WebRoutine sets sessionstatus active
WebRoutine Name(init) Onentry(*SESSIONSTATUS_NONE)
#com_owner.sessionstatus := active
Message Msgtxt('Session is now active')
Transfer Toroutine(search)
Endroutine
* Perform search and display results.
WebRoutine Name(search) Desc('Build a list of employees')
Web_Map For(*both) Fields(#surname)
Web_Map For(*output) Fields(#empnew)
Endroutine
* Load and display a list, from the saved list
WebRoutine Name(showsave) Desc('Show saved list of employees')
Web_Map For(*output) Fields(#empdisp)
Endroutine
Case (#stdrentry)
When (= S)
Clr_List Named(#empnew)
Begincheck
Valuecheck Field(#surname) With_List(*BLANK) In_List(*ERROR) Not_Inlist(*NEXT) Msgtxt('Surname may not be blank')
Endcheck
Select Fields(#empsave) From_File(pslmst2) With_Key(#surname) Nbr_Keys(*compute) Generic(*yes)
Add_Entry To_List(#empnew)
Add_Entry To_List(#empsave)
Endselect
Endcase
Add the initial logic to the showsave WebRoutine
Your code should look like the following:
Case (#stdrentry)
When (= L)
If (#std_count > 1)
Clr_List Named(#empdisp)
Selectlist Named(#empsave)
Add_Entry To_List(#empdisp)
Endselect
Else
Message Msgtxt('Saved employee list is empty')
Transfer Toroutine(search)
Endif
Endcase
Add an event handling routine for session invalid to transfer to the search init WebRoutine. Your code should look like the following:
Evtroutine Handling(#COM_OWNER.sessioninvalid)
Message Msgtxt('Session Management must be active')
Transfer Toroutine(init)
Endroutine
Compile the WAM.
Open the Search WebRoutine in the Design view. Add a column to the table containing employee surname. Drop a push button into the new column. Set up the button properties:
Property | Value |
|---|---|
caption |
|
on_click_wrname |
|
submitExtraFields |
|
|
Add a few blank lines below the table containing the employees list and insert a table with 1 row and 3 columns. Drop a push button into the left hand column and set up the button properties:
Property | Value |
|---|---|
Caption |
|
On_click_wrname |
|
submitExtraFields |
|
|
Adjust the width of the push button to show the caption as a single line.
Save your changes.
Your page should look like the following:
Open the showsave WebRoutine in the Design view. Select the list, move the cursor right and press enter to create a blank line below the list. Drop a push button below the list and set up its properties:
Property | Value |
|---|---|
Caption |
|
On_click_wrname |
|
submitExtraFields |
|
|

Q. Why is the list empty?
A. The persistent data is only restored if the session is already active. Running WebRoutine init starts a new session.