Step 2 Add List Paging Images weblet

LANSA WAM

Step 2. Add List Paging Images weblet

WAM065 - Controlling List Output

1.  Click anywhere in the employee list and use the context menu, Table Items / Add Rows… to add one row to the bottom of this table.

     Hint: Click in one of the columns such as Given Name and then use the context menu.

2.  Select inside the left hand cell of this new row and use the Details tab to set its colspan to 5.

3.  Drag a List paging images weblet into the new row. Your web page should look like the following:

4.  Save your changes.

5.  Select the list paging images weblet and use the Details tab to set up its properties:

Property

Value

prevcondfield

STDPREV

nextcondfield

STDMORE

Rentryfield

STDRENTRY

on_page_wrname

page

on_search_wrname

search

 

     You will observe that STDPREV, STDMORE and STDRENTRY are already defined. All these fields are defined in the repository. To use this weblet you must ensure they are mapped appropriately.

     The WebRoutine page is not yet defined, so you must type in this value.

6.  Save your changes.

You'll find a detailed definition of all weblets in the Web Application Modules guide.

STDPREV and STDMORE are used to show or hide the next and previous images. STDPREV = Y will hide the previous image.

The weblet returns a value in STDRENTRY when the more or previous image is selected.

  • The more image returns M in STDRENTRY
  • The previous image returns P in STDRENTRY
  • The search image returns blank in STDRENTRY.

7.  Add STDPREV and STDMORE as hidden fields in the global web_map, which should now look like the following:

* Global Maps

Web_Map For(*both) Fields((#stdrentry *hidden) (#empnof *hidden) (#empnow *hidden) (#cur_page *hidden) (#stdmore *hidden) (#stdprev *hidden))

8.  Create a page WebRoutine based on the following:

WebRoutine Name(page)
Web_Map For(*both) Fields(#empfrom #empto)
Web_Map For(*output) Fields(#emplist)
Case (#stdrentry)
When (= M)
#com_owner.browse I_Empfrom(#empnow) I_Empto(#empto)
When (= P)
#com_owner.previous I_Empfrom(#empnof) I_Empto(#empfrom)
Endcase
#stdrentry := D
Transfer Toroutine(search)
Endroutine
 

Ignore errors  shown because the previous method routine does not yet exist.

Review the page WebRoutine which:

  • Maps fields EMPFROM and EMPTO, in and out.
  • Maps the list EMPLIST out.
  • EMPNOF and EMPNOW represent the first and last entry in the list EMPLIST.
  • For more, the browse method routine is invoked with EMPNOW as the from employee number value.
  • For previous, the previous method routine is invoked with EMPNOF as the from employee number value.

9.  Create the previous method routine based on the following:

Mthroutine Name(previous)
Define_Map For(*input) Class(#empno) Name(#i_empfrom)
Define_Map For(*input) Class(#empno) Name(#i_empto)
Clr_List Named(#emplist)
Select Fields(*all) From_File(pslmst) Where((#std_count <= 10) And (#empno >= #i_empto)) With_Key(#i_empfrom) Val_Error(*next) Options(*startkey *endwhere *backwards)
Add_Entry To_List(#emplist) After(*start)
If (#std_count = 1)
#empnow := #EMPNO
Else
#empnof := #EMPNO
Endif
Endselect
#cur_page -= 1
If_Status Is(*beginfile)
Message Msgtxt('No more records')
#stdprev := *blank
Else
#stdprev #stdmore := Y
Endif
Endroutine
 

Review the previous method routine, which:

  • Maps in from employee number and to employee number values.
  • Clears the list EMPLIST
  • Selects record from file PSLMST with a startkey, reading backwards, with an endwhere condition.
  • The read ends when 10 record have been added to the list, or the current employee number is equal to or greater than the I_EMPTO value. This field contains the 'From Employee' value.
  • EMPNOF and EMPNOW are maintained, allowing for the read being backwards.
  • Current page number (CUR_PAGE) is decremented.
  • Beginning of file is detected with a message.
  • STDPREV and STDMORE are maintained, and control showing and hiding the more and previous images.

10. Extend the browse method routine to:

  • Manage STDPREV and STDMORE
  • Detect end of file
  • Detect the employee number to value has been reached.

     Your code should look like the following.  Existing code is shown in red.

. . . . 
Endselect

#cur_page += 1

If (#cur_page >= 2)
#stdprev := Y
Else
#stdprev := *blanks
Endif
If_Status Is(*endfile)
Message Msgtxt('No more records')
#stdmore := *blank
Endif
If (#empno >= #empto)
Add_Entry To_List(#emplist)
Message Msgtxt('End of Search')
#stdmore := *blank
Endif
Endroutine
 

11. In the Search WebRoutine add code to initialize the STDPREV and STDMORE fields.

     Your code should look like the following. New code is shown in red.

When (= s)* Search Button#stdprev := *blank#stdmore := Y#com_owner.browse I_Empfrom(#empfrom) I_Empto(#empto)

12.  Compile and test your WAM in the browser.

a.  With search values such as from A0070 to A2000 you should be able to page forward until A2000 is reached and then page back until A0070 is reached.

b.  Perform a search from A0070 to A0090. The more and previous images should not be displayed.

13. Note that when the Search web page is initially displayed, the list images weblet is shown. To hide this when the page is initially displayed, make the following changes:

a.  Add the field STD_COUNT to the global WEB_MAP as a hidden field

b.  Define the hide_if property for the std_list_images as:

#STD_COUNT = 0

     Add this logic in the Xpath expression editor for the hide_if property. Note that the field name must be in upper case.

14. Save your changes and re-test your WAM. The list images weblet should be hidden when the Search page is first displayed.