Step 3 Add AutoComplete Weblets optional

LANSA WAM

Step 3. Add AutoComplete Weblets (optional)

WAM065 - Controlling List Output

This step adds Autocomplete weblets for the To and From employee number fields. You may choose not to complete this step to save time.

At present, to use this enquiry you need to know suitable employee numbers. Adding an AutoComplete weblet for the from and to employee fields and a supporting response WebRoutine, will bring back and display a list of matching employee numbers as you type into the weblet.

1.  Create the Empno_Prompt response WebRoutine based on the following code:

WebRoutine Name(Empno_Prompt) Response(*JSON)
Web_Map For(*input) Fields(#empno)
Web_Map For(*output) Fields((#emp_dd *json))
Def_List Name(#emp_dd) Fields(#empno #std_code) Counter(#std_count) Type(*Working)
Clr_List Named(#emp_dd)
Select Fields(#emp_dd) From_File(pslmst) Where(#std_count <= 3) With_Key(#empno) Options(*startkey *endwhere)
#std_code := #empno
Add_Entry To_List(#emp_dd)
Endselect
Endroutine
 

The Empno_Response WebRoutine:

  • Must have the Response(*JSON) keyword on the WebRoutine statement. This routine will be called by the AutoComplete weblet and returns a small list of employee numbers as JSON data.
  • Maps the field EMPNO for input
  • Maps the list EMP_DD for output as JSON data.
  • Defines a working list EMP_DD containing EMPNO. A second field has been added to ensure the fields are recognized by the Details tab dialog.
  • Clears the list EMP_DD
  • Selects up to 3 entries from the file PSLMST using EMPNO as a startkey
  • Adds entries to the list EMP_DD
  • Returns the list EMP_DD to the AutoComplete weblet.

2.  Compile your WAM.

3.  Open the search WebRoutine in the Design view.

4.  Drop an AutoComplete weblet onto to the EMPFROM field and the EMPTO field.

5.  Set up both AutoComplete weblets as follows:

Property

Value

minLength

2

Delay

150

sourceWrName

Empno_Prompt

termField

EMPNO

listName

EMP_DD

valueField

EMPNO

 

     For more information on all weblets see the Web Application Modules Guide.

     See also the help available for each property from the Details tab:

     The minLength value is the characters to be typed before the WebRoutine is called

     The delay value is the number of milliseconds the weblet waits to activate itself after the last keystroke.

     The termField is the value passed to the WebRoutine defined in sourceWrName.

     The listName is the response list to be displayed as a dropdown list.

     The valueField is the list value to be displayed.

6.  If necessary reduce the width of the AutoComplete input boxes to suit the field EMPNO (up to 5 characters).

7.  Save your changes.

8.  Execute your WAM in the browser and test the AutoComplete weblet. You should get the following results: