Step 2. Add List Paging Images weblet
WAM065 - Controlling List Output
1. In the
view, click anywhere in the employee list and use the context menu, 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
tab to set its colspan to 5.3. Drag a
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
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
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
or 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:
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:
10. Extend the browse method routine to:
Your code should look like the following. New 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 (or the next nearest record if A2000 does not exist) and then page back until A0070 is reached.
b. Perform a search from A0070 to A0090. The
and images should not be displayed.13. Notice 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. Open the Search webroutine in the
view and select the std_list_images weblet. Define the property for the std_list_images as:#STD_COUNT = 0
This logic must be added in the Xpath expression editor for the
property. Note that the field name must be in upper case.14. Recompile your WAM and re-test. The list images weblet should be hidden when the Search page is first displayed.