|
> but how simple / hard is it to format template pages > to be fed properly to the apis, how well does the > substitution, row/column, looping schemes each one > uses work in the real word, etc. Rick, Included with my remarks is source code for a program that supports hierarchical menu navigation. Menus may contain links to sub-menus as well as links to program items. Sub-menus may be nested up to ten (10) levels deep. The program illustrates a typical use of the Relational-Web API. Relational-Web procedure calls replace "Field" markers embedded in an HTML template, with program data coming from the database. Simple "Record" markers in HTML templates delimit relevant blocks of HTML. <!RECORD:ONE> <html> <body> <p>{{field}} comes from the database</p> </body> </html> * set pointer to record ONE Callp wtnRecSet('ONE') * insert something relevant into the output stream Callp wtnFldSet('field':'Something relevant') * send the HTML block to the browser Callp wtnRecWrt('ONE') My preference is to completely separate program logic from user interface definition (HTML, XML, etc.). This approach leads to readable code. One final thought. Notice the call to wtnOpen('MENU_HTML'), which loads one or more HTML files into memory. In this case 'MENU_HTML' is the name of a source file member containing a list of stream files to read. Nathan. *----------------------------------------------------------------- /COPY *LIBL/QRPGLESRC,RDWTNAPI#1 /COPY *LIBL/QRPGLESRC,RDSTRAPI#1 /COPY *LIBL/QRPGLESRC,MENUPROG#1 /COPY *LIBL/QRPGLESRC,MENUDATA#1 *----------------------------------------------------------------- D showMenu PR D 10A Const *----------------------------------------------------------------- D sessDs E DS Extname(menusess:menusessr) D Import *----------------------------------------------------------------- D menuList E DS Extname(aee100ms:aee100msr) D Occurs(100) Import *----------------------------------------------------------------- D itemList E DS Extname(aee100mi:aee100mir) D Occurs(100) Import * ---------------------------------------------------------------- D menuAry S 10A Dim(8) Based(menuArp) D menuArp S * Inz(%addr(ss_mnu_ary)) D i S 10U 0 D recordCt S 10U 0 * ---------------------------------------------------------------- P initProgram B Export * ---------------------------------------------------------------- C Callp initDataIO C Callp wtnOpen('MENU_HTML') P initProgram E * ---------------------------------------------------------------- P endProgram B Export * ---------------------------------------------------------------- C Callp endDataIO C Callp wtnClose P endProgram E * ---------------------------------------------------------------- P menuTop B Export * ---------------------------------------------------------------- C Eval ss_mnu_ndx = 1 C Eval menuAry(ss_mnu_ndx) = ss_mgrp C Callp showMenu (menuAry(ss_mnu_ndx)) P menuTop E * ---------------------------------------------------------------- P selectMenu B Export * ---------------------------------------------------------------- C Eval ss_mnu_ndx = strToInt(wtnQryGet('menu')) C If ss_mnu_ndx < 1 or ss_mnu_ndx > 8 C Eval ss_mnu_ndx = 1 C Endif C Callp showMenu (menuAry(ss_mnu_ndx)) P selectMenu E * ---------------------------------------------------------------- P menuDetail B Export * ---------------------------------------------------------------- C If ss_mnu_ndx < 8 C Eval ss_mnu_ndx = ss_mnu_ndx + 1 C Endif C Eval menuAry(ss_mnu_ndx) = wtnQryGet('menu') C Callp showMenu (menuAry(ss_mnu_ndx)) P menuDetail E * ---------------------------------------------------------------- P showMenu B *----------------------------------------------------------------- D showMenu PI D menu 10A Const * ---------------------------------------------------------------- D odd S N Inz(*on) * ---------------------------------------------------------------- C Callp wtnRecWrt('MENU01') C For i = 1 to ss_mnu_ndx C Callp wtnRecSet('MENU02') C Callp wtnFldSet('menu':%char(i)) C Callp wtnFldSet('desc':getMenuDesc( C menuAry(i))) C Callp wtnRecWrt('MENU02') C Endfor C Callp wtnRecWrt('MENU03') * ---------------------------------------------------------------- C Eval recordCt = getSubMenus(menu) C If recordCt > 0 C Exsr bldMenuList C Else C Callp wtnRecWrt('MENU04') C Endif C Eval recordCt = getMenuItems(menu) C If recordCt > 0 C Exsr bldItemList C Endif C Callp wtnRecWrt('MENU04') * ---------------------------------------------------------------- C bldMenuList Begsr * ---------------------------------------------------------------- C Callp wtnRecWrt('MENU05') C Callp wtnRecWrt('MENU06') C For i = 1 to recordCt C i Occur menuList C If odd C Eval odd = *off C Callp wtnRecWrt('MENU07') C Callp wtnRecSet('MENU08') C Callp wtnFldSet('menu':%trimr(ms_menu)) C Callp wtnFldSet('desc':ms_desc) C Callp wtnRecWrt('MENU08') C Else C Eval odd = *on C Callp wtnRecSet('MENU08') C Callp wtnFldSet('menu':%trimr(ms_menu)) C Callp wtnFldSet('desc':ms_desc) C Callp wtnRecWrt('MENU08') C Callp wtnRecWrt('MENU09') C Endif C Endfor * ---------------------------------------------------------------- C If not odd C Callp wtnRecWrt('MENU09') C Endif C Callp wtnRecWrt('MENU10') C Endsr * ---------------------------------------------------------------- C bldItemList Begsr * ---------------------------------------------------------------- C Eval odd = *on C Callp wtnRecWrt('MENU05') C Callp wtnRecWrt('MENU06') C For i = 1 to recordCt C i Occur itemList C If odd C Eval odd = *off C Callp wtnRecWrt('MENU12') C Callp wtnRecSet('MENU13') C Callp wtnFldSet('des2':mi_desc) C Callp wtnFldSet('des1':mi_desc) C Callp wtnFldSet('type':mi_type) C Callp wtnFldSet('item':%trimr(mi_item)) C Callp wtnRecWrt('MENU13') C Else C Eval odd = *on C Callp wtnRecSet('MENU13') C Callp wtnFldSet('des2':mi_desc) C Callp wtnFldSet('des1':mi_desc) C Callp wtnFldSet('type':mi_type) C Callp wtnFldSet('item':%trimr(mi_item)) C Callp wtnRecWrt('MENU13') C Callp wtnRecWrt('MENU14') C Endif C Endfor C If not odd C Callp wtnRecWrt('MENU14') C Endif C Callp wtnRecWrt('MENU10') C Endsr P showMenu E
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.