Step 1. Create the Login WAM

1.  Create a new WAM with:

     Name: iiiAppLogin

     Description: Application Login

     Layout weblet: iiilay01

2.  Press F7 to display WAM properties. Use the Details tab to make SessionStatus active and define a SessionGroupName of iiisession.

3.  Add the following definitions of fields and lists which will define the menu

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)


4.  Add the following WEB_MAPs:

Web_Map For(*output) Fields((#mnulist *private))
Web_Map For(*none) Fields(#mnusave) Options(*persist)
Web_Map For(*both) Fields((#stdrentry *hidden))


     Note the way that the map for list MNUSAVE is defined. This is the persistent version of the menu list which will be shared by all WAMs making up this application.

5.  Define a WebRoutine login, which has an onentry parameter of *sessionstatus_none. This WebRoutine will establish a session for valid users and execute the subroutines to build the menu list.

Webroutine Name(login) Onentry(*SESSIONSTATUS_NONE)
Web_Map For(*both) Fields(#userid #passwd)
Message Msgtxt('Enter your user id and password')

     Note that the fields USERID and PASSWD are mapped for *both. If these fields do not exist in the Repository, define them in your WAM as:

Define Field(#USERID) Type(*char) Length(10) Desc("User ID")

Define Field(#PASSWD) Type(*char) Length(10) Desc("Password") Input_Atr(ND)


6.  Define a method routine AddToMenu which will add each entry to the menu list MNUSAVE. It requires six input parameters which will define the required menu field entries. You will find this information in the Web Applications Modules Guide / 8.1.18 Menubar (std_menubar). Your code should look like the following:

Mthroutine Name(AddToMenu)
Define_Map For(*input) Class(#STD_STRNG) Name(#itmid)
Define_Map For(*input) Class(#STD_STRNG) Name(#pitmid)
Define_Map For(*input) Class(#STD_DESC) Name(#caption)
Define_Map For(*input) Class(#STD_STRNG) Name(#URL)
Define_Map For(*input) Class(#STD_DESCS) Name(#WAM)
Define_Map For(*input) Class(#STD_DESCS) Name(#WRNAME)
#mnuitmid := #itmid
#prtitmid := #pitmid
#mnucapt := #caption
#mnuurl := #URL
#mnuwam := #WAM
#mnuwrnme := #WRNAME
Add_Entry To_List(#mnusave)


     If necessary add field STD_STRNG to the Repository as a STRING field, length 512.

7.  Define a subroutine buildmenu which will add the standard menu entries which will be available for all users. This subroutine will be invoked once when the user logs in, so it should begin by clearing MNUSAVE. It should call the method routine AddToMenu to define and add each menu entry. Your code should look like the following:

Subroutine Name(buildmenu)
Clr_List Named(#mnusave)
* Home
#com_owner.addtomenu Itmid('1') Pitmid('') Caption('Home') Url('') Wam('') Wrname('')
* Applications
#com_owner.addtomenu Itmid('2') Pitmid('') Caption('Applications') Url('') Wam('') Wrname('')
* Support
#com_owner.addtomenu Itmid('3') Pitmid('') Caption('Support') Url('') Wam('') Wrname('')
* Contact Us
#com_owner.addtomenu Itmid('4') Pitmid('') Caption('Contact Us') Url('') Wam('') Wrname('')
* About
#com_owner.addtomenu Itmid('5') Pitmid('') Caption('About') Url('') Wam('') Wrname('')

8.  Define a subroutine buildapps which will only be executed for the ADMIN user, which adds entries for the Employees menu and sub-menu items. It should not clear the list MNUSAVE. Your code should look like the following.

     As before you must look in the Repository for your WAMs and note their Identifiers and replace the values shown in the code below..

Subroutine Name(buildapps)
* Employees
#com_owner.addtomenu Itmid('50') Pitmid('2') Caption('Employees') Url('') Wam('') Wrname('')
* enquiry
#com_owner.addtomenu Itmid('51') Pitmid('50') Caption('Enquiry') Url('') Wam(IIIEMPEN) Wrname(BEGIN)
* Update
#com_owner.addtomenu Itmid('52') Pitmid('50') Caption('Update') Url('') Wam(IIIEMPUP) Wrname(BEGIN)
* Update with Dropdowns
#com_owner.addtomenu Itmid('53') Pitmid('50') Caption('Update with Dropdowns') Url('') Wam(IIIEMP_3) Wrname(BEGIN)
* Update using Dropdown with Selector
#com_owner.addtomenu Itmid('54') Pitmid('50') Caption('Update using Dropdown with selector') Url('') Wam(IIIEMP_4) Wrname(BEGIN)

     Note: All menu entries must have a unique id. Sub-menu items must also have the correct parent id.

9.  Define a new WebRoutine welcome. The login WebRoutine will transfer to this after a valid login. Welcome will clear and populate the output menu list MNULIST and display "welcome" messages. Your code should look like the following:

Webroutine Name(welcome)
Web_Map For(*input) Fields(#userid)
Clr_List Named(#mnulist)
Selectlist Named(#mnusave)
Add_Entry To_List(#mnulist)
Message Msgtxt('Welcome ' + #USERID) Type(*STATUS)
Message Msgtxt('You are logged into the Personnel Applications System') Type(*status)


     Note that the USERID is mapped into this WebRoutine so that it's available in the welcome message.

10. In this step you will complete the login WebRoutine.

     The login button will be set up to return STDRENTRY with a value of L.

     A CASE loop for field USERID will check password, make the session status active, and execute one or both build menu subroutines. It will then transfer to the welcome WebRoutine. Your completed login WebRoutine should look like the following:

Webroutine Name(login) Onentry(*SESSIONSTATUS_NONE)
Web_Map For(*both) Fields(#userid #passwd)
Message Msgtxt('Enter your user id and password')
If (#stdrentry = L)
Case (#userid)
When (= ADMIN)
If (#passwd = '14MIN')
#com_owner.sessionstatus := active
Execute Subroutine(buildmenu)
Execute Subroutine(buildapps)
Transfer Toroutine(welcome)
Message Msgtxt('Password incorrect for this user')
When (= USER)
If (#passwd = 'US5R')
#com_owner.sessionstatus := active
Execute Subroutine(buildmenu)
Transfer Toroutine(welcome)
Message Msgtxt('Password incorrect for this user')


11. Compile your WAM.

12. Open the login WebRoutine in the Design view.

a.  Add a row to the bottom of the fields table

b.  Add a push button with image to the bottom right hand cell

c.  Set up the push button as follows:

Property Value


Log In








Literal Value: L


13.  Save your changes.