More than 1 parameter passed to oprop.action <PAGES> tag returns only 1

Jul 21, 2009 at 12:24 PM

When passing more than 1 parameter to a webpage eg. action=clientnr&clientname=XXX&surname=XXX 1st page data is returned correct.

Any further pages only pass 1 param to the next page. eg action=clientnr which is the oprop.action value.

Is there any way, excluding, modifying the ACTIVEVFP.PRG file with another variable so that the pages marked 2,3,4,5 will include the correct parameters?

Thanks for the help.

 

Coordinator
Jul 21, 2009 at 2:52 PM

Hmm, that might actually be a bug.  At first glance, it should pass whatever you're putting on the url and just append anything else that's necessary.  If this is the case, then I might need to modify activevfp.prg.  (I'll include the fix in AVFP 5 which hopefully will be released this week.  (AVFP 5 will add support for VFP Web Services called from ASMX pages))

Thanks for bringing this to my attention!

Coordinator
Jul 21, 2009 at 5:10 PM
Take a look at this now and let me know if it would work for you: 

http://72.196.251.129:443/avfpdemo4/default.aspx?action=simplelist&fi=fo&fo=fi

The page numbers after 1 should have appended variables but you would also need to use a new parameter
in htmlTable method called lcExtra that you can pass a string to be appended
to the URL for page numbers. Not pretty or elegant but it seems to work.

Here's the modified section from SimpleList in main.prg:

CASE oProp.Action=='simplelist'
    SELE * FROM Customer INTO CURSOR tCursor
    lcHTMLfile = 'custlist.htm'  && html template
    lcHTMLout= FILETOSTR(oProp.HtmlPath+lcHTMLfile)
    lcHTMLout= oHTML.htmlTable('customers',lcHTMLout,10,5,'#E5E5E5',.F.;
        ,VAL(oRequest.querystring("page")),oRequest.querystring("nav"),[&fi=fo&fo=fi])
    lcHTMLout= oHTML.mergetext(lcHTMLout)

and here's the new htmlTable method:

************************************************************************
* AVFPhtml :: htmltable
************************************************************************
* HTMLTABLE - eval html tables
*
* Last Modified: 7/21/09
*
***  1.) lcTableTag   -Name of the HTML table (from <htmltablename> in HTML)
***  2.) lcHTMLtable  -HTML table text to be evaluated
***  3.) lnTotPerPage -Total number of records per page
***  4.) lnpagenumbers-Include page numbers/# of page numbers to show(need to include lnStart and lcButton params)
***  5.) lcBar        -Alternating color for HTML table records (for example, #FFFFFF for white)
***  6.) llTableRec   -(fast write)<table>record</table>&do a response.write - for fastest output(usually a large list on 1 page)
***  7.) lnStart      -Navigational - Page number to start list from, from URL
***  8.) lcButton     -Navigational - First, last, next, previous, from URL
***  8.) lcExtra      -Extra QueryString params to pass on the URL
************************************************************************
FUNCTION htmltable
LPARAMETERS lcTableTag,lcHTMLtable,lnTotPerPage,lnpagenumbers,lcBar,;
    llTableRec,lnStart,lcButton,lcExtra
LOCAL lnRowCount,lnTotPages,lnAtPos,lnAtPos1,lnAtPos2,lcHTML,;
    lnPageMax,lnPageBegin,lcPages,lnOccur,lcHTMLstr,lcStr1,lcStr2,;
    lnCount,lnX,lnZ,lcBarStr,lcDivStart,lcDivEnd, llpagenumbers
IF lnpagenumbers > 0 .AND. ISNULL(lnpagenumbers) != .T.
    llpagenumbers=.T.
ELSE
    llpagenumbers=.F.
ENDIF
IF EMPTY(lcExtra)
    lcExtra=[]
ENDIF
lcHTML=''
lcHTMLstr=lcHTMLtable
lnAtPos1 = ATC('&lt;'+ALLTRIM(lcTableTag)+'&gt;', lcHTMLstr)
IF lnAtPos1 = 0
    lnAtPos1 = ATC('<'+ALLTRIM(lcTableTag)+'>', lcHTMLstr)
    lcDivStart=THIS.GetString(SUBSTR(lcHTMLstr,lnAtPos1),;
        '<'+ALLTRIM(lcTableTag)+'>','<TABLE ')
ELSE
    lcDivStart=THIS.GetString(SUBSTR(lcHTMLstr,lnAtPos1),;
        '&lt;'+ALLTRIM(lcTableTag)+'&gt;','<TABLE ')
ENDIF
lnAtPos2 = ATC('&lt;/'+ALLTRIM(lcTableTag)+'&gt;', lcHTMLstr)
IF lnAtPos2 = 0
    lnAtPos2 = ATC('</'+ALLTRIM(lcTableTag)+'>', lcHTMLstr)
    lcDivEnd=THIS.GetString(SUBSTR(lcHTMLstr,lnAtPos1),;
        '</TABLE>','</'+ALLTRIM(lcTableTag)+'>')
ELSE
    lcDivEnd=THIS.GetString(SUBSTR(lcHTMLstr,lnAtPos1),;
        '</TABLE>','&lt;/'+ALLTRIM(lcTableTag)+'&gt;')
ENDIF
lnOccur=OCCURS('<TABLE ',UPPER(lcHTMLstr))
FOR lnCount = 1 TO lnOccur
    lnAtPos=ATC('<TABLE ',lcHTMLstr,lnCount)
    IF lnAtPos >lnAtPos1 .AND. lnAtPos< lnATPos2
        EXIT
    ENDIF
ENDFOR
IF lnAtPos > 0
    lcStr1     = LEFT(lcHTMLstr, lnAtPos - 1)
    lcHTMLstr = SUBSTR(lcHTMLstr, lnAtPos)
    lnAtPos    = ATC('</TABLE>', lcHTMLstr)
    lcStr2    = LEFT(lcHTMLstr, lnAtPos - 1)
    lcHTMLstr = SUBSTR(lcHTMLstr, lnAtPos)
    IF llTableRec
        lcTableStr="<Table "+THIS.GetString(lcStr2,"<TABLE ",">")+">"
    ENDIF
    lnAtPos = ATC('<TR', lcStr2)
    IF lnAtPos > 0
        lcStr1  = LEFT(lcStr2, lnAtPos - 1)
        lcStr2 = SUBSTR(lcStr2, lnAtPos)
        lcHTML = lcHTML + THIS.mergetext(lcStr1)
    ENDIF
    DO WHILE ATC('<TH', lcStr2) > 0
        lnAtPos = ATC('</TR>', lcStr2)
        lcStr1  = LEFT(lcStr2, lnAtPos + 5)
        lcStr2 = SUBSTR(lcStr2, lnAtPos + 5)
        lcHTML = lcHTML + IIF(llTableRec,lcTableStr+THIS.mergetext(lcStr1)+[</TABLE>],;
            THIS.mergetext(lcStr1))
    ENDDO
    lnRowCount = RECCOUNT()
    RELEASE START
    PUBLIC START
    IF llpagenumbers
        START = NVL(lnStart,1)
        IF START = 0
            START= 1
        ENDIF
        lnPageMax = START * lnTotPerPage
        lnPageBegin = (lnPageMax - lnTotPerPage)+1
        IF lnRowCount < lnTotPerPage
            lnTotPages = 1
        ELSE
            IF MOD(lnRowCount, lnTotPerPage) > 0
                lnTotPages = INT(lnRowCount / lnTotPerPage) + 1
            ELSE
                lnTotPages = INT(lnRowCount / lnTotPerPage)
            ENDIF
        ENDIF        
        oSession.value("totpages",lnTotPages)
        DO CASE
        CASE lcButton="First"
            START=1
            lnPageBegin=1
            lnPageMax=lnTotPerPage
        CASE lcButton="Prev"
            IF lnPageBegin < 1 .OR. START -1 = 0
                START=1
                lnPageBegin=1
                lnPageMax=lnTotPerPage
            ELSE
                START=START-1
                lnPageBegin=lnPageBegin-lnTotPerPage
                lnPageMax=lnPageMax-lnTotPerPage
            ENDIF
        CASE lcButton="Next"
            START=START+1
            IF START>lnTotPages
                START = lnTotPages
                lnPageMax =  START * lnTotPerPage
                lnPageBegin = (lnPageMax - lnTotPerPage)+1
                lnPageMax = lnRowCount
            ELSE
                lnPageBegin=lnPageBegin+lnTotPerPage
                lnPageMax=lnPageMax+lnTotPerPage
            ENDIF
        CASE lcButton="Last"
            START=lnTotPages
            lnPageMax =  START * lnTotPerPage
            lnPageBegin = (lnPageMax - lnTotPerPage)+1
            lnPageMax = lnRowCount
        OTHERWISE
            IF EMPTY(START)
                START=1
                lnPageBegin=1
                lnPageMax=lnTotPerPage
            ENDIF
        ENDCASE
    ELSE
        START=1
        lnPageBegin=1
        lnPageMax=lnTotPerPage
    ENDIF
    IF llTableRec
        lnTH=OCCURS('</th>',lcHTMLtable)
        lnTHat=AT('<th',lcHTMLtable)
        lnTHat2=AT('</th>',lcHTMLtable,lnTH)
        oResponse.Write(ALLTRIM(This.mergetext(SUBSTR(lcHTMLtable,1,lnTHat-1))+[</tr>]))
        oResponse.Write(lcTableStr+This.mergetext(SUBSTR(lcHTMLtable,lnTHat,(lnTHat2-lnTHat)+5)))
    ENDIF
    FOR lnX = lnPageBegin TO IIF(llpagenumbers,lnPageMax,lnRowCount)
    
        IF lnX <= lnRowCount
            GOTO lnX
            IF !EMPTY(lcBar)
                IF MOD(lnX,2) = 0
                    lcBarStr=STRTRAN(lcStr2,[<TD],[<TD bgcolor="]+lcBar+["])
                    lcBarStr=STRTRAN(lcBarStr,[<td],[<td bgcolor="]+lcBar+["])
                    lcBarStr=STRTRAN(lcBarStr,[<Td],[<td bgcolor="]+lcBar+["])
                    lcBarStr=STRTRAN(lcBarStr,[<tD],[<td bgcolor="]+lcBar+["])
                    IF llTableRec
                        lcHTML = lcTableStr+THIS.mergetext(lcBarStr)
                    ELSE
                         lcHTML = lcHTML +THIS.mergetext(lcBarStr)
                    ENDIF
                ELSE                    
                    IF llTableRec
                        lcHTML=lcTableStr+THIS.mergetext(lcStr2)
                    ELSE
                        lcHTML = lcHTML + THIS.mergetext(lcStr2)
                    ENDIF
                ENDIF
            ELSE
                IF llTableRec
                    lcHTML = lcTableStr+THIS.mergetext(lcStr2)
                ELSE
                    lcHTML = lcHTML + THIS.mergetext(lcStr2)
                ENDIF
            ENDIF
            IF llTableRec
                oResponse.Write(lcHTML+[</TABLE>])
                oResponse.Flush
            ENDIF
        ENDIF
    ENDFOR
    IF llTableRec
        oResponse.Write([</TD></TR></TBODY></TABLE></BODY></HTML>])
    ELSE
        lcHTML=THIS.mergetext(lcDivStart)+lcHTML+"</TABLE>"+THIS.mergetext(lcDivEnd)
        lcHTMLtable  =STUFF(lcHTMLtable, lnAtPos1, lnAtPos2 - lnAtPos1+;
            LEN(lcTableTag)+9, lcHTML)
        IF llpagenumbers
            lcPages=''
            IF lnTotPages > 1
                lngroupnumber = ceiling(START/lnpagenumbers)
                FOR lnZ = lngroupnumber*lnpagenumbers-(lnpagenumbers-1) TO IIF(lnTotpages<lngroupnumber*lnpagenumbers,lnTotPages,lngroupnumber*lnpagenumbers) &&lnTotPages
                      IF lnZ=START
                        lcPages=lcPages+[ <B>]+ALLTRIM(STR(lnZ))+[</B> ]+crlf
                      ELSE
                        lcPages=lcPages+[ <a href="]+oProp.ScriptPath +[?action=];
                        +oProp.Action+[&sid=]+oProp.SessID+[&page=]+ALLTRIM(STR(lnZ))+[&nav=]+lcExtra+[">];
                        +ALLTRIM(STR(lnZ))+[</a> ]+crlf
                            
                      ENDIF
                ENDFOR
            ENDIF
            lnAtPos = ATC("&lt;Pages&gt;",lcHTMLtable)
            IF lnAtPos = 0
                lnAtPos = ATC("<Pages>",lcHTMLtable)
            ENDIF
            IF ! EMPTY(lcPages) .AND. lnAtPos > 0
                lcHTMLtable= STUFF(lcHTMLtable,lnAtPos,13,lcPages)+crlf
            ELSE
                lcHTMLtable= STUFF(lcHTMLtable,lnAtPos,13,"")+crlf
            ENDIF
        ENDIF
    ENDIF
ENDIF
RETURN lcHTMLtable
Jul 22, 2009 at 8:13 AM

Claude

Thank you I tested it and it works very good.

What would be nice would be if the next,top,prev,end links could also work something similar.

I still need to insert the additional parameters into hyperlink

Maybe I should create something like

osession.Value("Cpassed_params",’&custid=XXXX&custname=XXXXX’)

and then reference that value in the hyperlink.

Thanx again.

Cannot wait for Version 5.0

Regards

Hendrik Labuschagne


From: claudefox [mailto:notifications@codeplex.com]
Sent: 21 July 2009 06:11 PM
To: software@mhsoftware.co.za
Subject: Re: More than 1 parameter passed to oprop.action <PAGES> tag returns only 1 [activevfp:63061]

From: claudefox

Take a look at this now and let me know if it would work for you: 

http://72.196.251.129:443/avfpdemo4/default.aspx?action=simplelist&fi=fo&fo=fi

The page numbers after 1 should have appended variables but you would also need to use a new parameter
in htmlTable method called lcExtra that you can pass a string to be appended
to the URL for page numbers. Not pretty or elegant but it seems to work.

Here's the modified section from SimpleList in main.prg:

CASE oProp.Action=='simplelist'
SELE * FROM Customer INTO CURSOR tCursor
lcHTMLfile = 'custlist.htm' && html template
lcHTMLout= FILETOSTR(oProp.HtmlPath+lcHTMLfile)
lcHTMLout= oHTML.htmlTable('customers',lcHTMLout,10,5,'#E5E5E5',.F.;
,VAL(oRequest.querystring("page")),oRequest.querystring("nav"),[&fi=fo&fo=fi])
lcHTMLout= oHTML.mergetext(lcHTMLout)

and here's the new htmlTable method:

************************************************************************
* AVFPhtml :: htmltable
************************************************************************
* HTMLTABLE - eval html tables
*
* Last Modified: 7/21/09
*
*** 1.) lcTableTag -Name of the HTML table (from <htmltablename> in HTML)
*** 2.) lcHTMLtable -HTML table text to be evaluated
*** 3.) lnTotPerPage -Total number of records per page
*** 4.) lnpagenumbers-Include page numbers/# of page numbers to show(need to include lnStart and lcButton params)
*** 5.) lcBar -Alternating color for HTML table records (for example, #FFFFFF for white)
*** 6.) llTableRec -(fast write)
&do a response.write - for fastest output(usually a large list on 1 page)
*** 7.) lnStart -Navigational - Page number to start list from, from URL
*** 8.) lcButton -Navigational - First, last, next, previous, from URL
*** 8.) lcExtra -Extra QueryString params to pass on the URL
************************************************************************
FUNCTION htmltable
LPARAMETERS lcTableTag,lcHTMLtable,lnTotPerPage,lnpagenumbers,lcBar,;
llTableRec,lnStart,lcButton,lcExtra
LOCAL lnRowCount,lnTotPages,lnAtPos,lnAtPos1,lnAtPos2,lcHTML,;
lnPageMax,lnPageBegin,lcPages,lnOccur,lcHTMLstr,lcStr1,lcStr2,;
lnCount,lnX,lnZ,lcBarStr,lcDivStart,lcDivEnd, llpagenumbers
IF lnpagenumbers > 0 .AND. ISNULL(lnpagenumbers) != .T.
llpagenumbers=.T.
ELSE
llpagenumbers=.F.
ENDIF
IF EMPTY(lcExtra)
lcExtra=[]
ENDIF
lcHTML=''
lcHTMLstr=lcHTMLtable
lnAtPos1 = ATC('<'+ALLTRIM(lcTableTag)+'>', lcHTMLstr)
IF lnAtPos1 = 0
lnAtPos1 = ATC('<'+ALLTRIM(lcTableTag)+'>', lcHTMLstr)
lcDivStart=THIS.GetString(SUBSTR(lcHTMLstr,lnAtPos1),;
'<'+ALLTRIM(lcTableTag)+'>','
lcDivStart=THIS.GetString(SUBSTR(lcHTMLstr,lnAtPos1),;
'<'+ALLTRIM(lcTableTag)+'>','

lnAtPos2 = ATC('</'+ALLTRIM(lcTableTag)+'>', lcHTMLstr)
IF lnAtPos2 = 0
lnAtPos2 = ATC('</'+ALLTRIM(lcTableTag)+'>', lcHTMLstr)
lcDivEnd=THIS.GetString(SUBSTR(lcHTMLstr,lnAtPos1),;
'
','</'+ALLTRIM(lcTableTag)+'>')
ELSE
lcDivEnd=THIS.GetString(SUBSTR(lcHTMLstr,lnAtPos1),;
'','</'+ALLTRIM(lcTableTag)+'>')
ENDIF
lnOccur=OCCURS(' FOR lnCount = 1 TO lnOccur
lnAtPos=ATC('
IF lnAtPos >lnAtPos1 .AND. lnAtPos< lnATPos2
EXIT
ENDIF
ENDFOR
IF lnAtPos > 0
lcStr1 = LEFT(lcHTMLstr, lnAtPos - 1)
lcHTMLstr = SUBSTR(lcHTMLstr, lnAtPos)
lnAtPos = ATC('
', lcHTMLstr)
lcStr2 = LEFT(lcHTMLstr, lnAtPos - 1)
lcHTMLstr = SUBSTR(lcHTMLstr, lnAtPos)
IF llTableRec
lcTableStr="")+">"
ENDIF
lnAtPos = ATC(' IF lnAtPos > 0
lcStr1 = LEFT(lcStr2, lnAtPos - 1)
lcStr2 = SUBSTR(lcStr2, lnAtPos)
lcHTML = lcHTML + THIS.mergetext(lcStr1)
ENDIF
DO WHILE ATC(' 0
lnAtPos = ATC('', lcStr2)
lcStr1 = LEFT(lcStr2, lnAtPos + 5)
lcStr2 = SUBSTR(lcStr2, lnAtPos + 5)
lcHTML = lcHTML + IIF(llTableRec,lcTableStr+THIS.mergetext(lcStr1)+[
],;
THIS.mergetext(lcStr1))
ENDDO
lnRowCount = RECCOUNT()
RELEASE START
PUBLIC START
IF llpagenumbers
START = NVL(lnStart,1)
IF START = 0
START= 1
ENDIF
lnPageMax = START * lnTotPerPage
lnPageBegin = (lnPageMax - lnTotPerPage)+1
IF lnRowCount < lnTotPerPage
lnTotPages = 1
ELSE
IF MOD(lnRowCount, lnTotPerPage) > 0
lnTotPages = INT(lnRowCount / lnTotPerPage) + 1
ELSE
lnTotPages = INT(lnRowCount / lnTotPerPage)
ENDIF
ENDIF
oSession.value("totpages",lnTotPages)
DO CASE
CASE lcButton="First"
START=1
lnPageBegin=1
lnPageMax=lnTotPerPage
CASE lcButton="Prev"
IF lnPageBegin < 1 .OR. START -1 = 0
START=1
lnPageBegin=1
lnPageMax=lnTotPerPage
ELSE
START=START-1
lnPageBegin=lnPageBegin-lnTotPerPage
lnPageMax=lnPageMax-lnTotPerPage
ENDIF
CASE lcButton="Next"
START=START+1
IF START>lnTotPages
START = lnTotPages
lnPageMax = START * lnTotPerPage
lnPageBegin = (lnPageMax - lnTotPerPage)+1
lnPageMax = lnRowCount
ELSE
lnPageBegin=lnPageBegin+lnTotPerPage
lnPageMax=lnPageMax+lnTotPerPage
ENDIF
CASE lcButton="Last"
START=lnTotPages
lnPageMax = START * lnTotPerPage
lnPageBegin = (lnPageMax - lnTotPerPage)+1
lnPageMax = lnRowCount
OTHERWISE
IF EMPTY(START)
START=1
lnPageBegin=1
lnPageMax=lnTotPerPage
ENDIF
ENDCASE
ELSE
START=1
lnPageBegin=1
lnPageMax=lnTotPerPage
ENDIF
IF llTableRec
lnTH=OCCURS('',lcHTMLtable)
lnTHat=AT('<th',lcHTMLtable)
lnTHat2=AT('',lcHTMLtable,lnTH)
oResponse.Write(ALLTRIM(This.mergetext(SUBSTR(lcHTMLtable,1,lnTHat-1))+[]))
oResponse.Write(lcTableStr+This.mergetext(SUBSTR(lcHTMLtable,lnTHat,(lnTHat2-lnTHat)+5)))
ENDIF
FOR lnX = lnPageBegin TO IIF(llpagenumbers,lnPageMax,lnRowCount)

IF lnX <= lnRowCount
GOTO lnX
IF !EMPTY(lcBar)
IF MOD(lnX,2) = 0
lcBarStr=STRTRAN(lcStr2,[<TD],[ lcBarStr=STRTRAN(lcBarStr,[<td],[ lcBarStr=STRTRAN(lcBarStr,[<Td],[ lcBarStr=STRTRAN(lcBarStr,[<tD],[ IF llTableRec
lcHTML = lcTableStr+THIS.mergetext(lcBarStr)
ELSE
lcHTML = lcHTML +THIS.mergetext(lcBarStr)
ENDIF
ELSE
IF llTableRec
lcHTML=lcTableStr+THIS.mergetext(lcStr2)
ELSE
lcHTML = lcHTML + THIS.mergetext(lcStr2)
ENDIF
ENDIF
ELSE
IF llTableRec
lcHTML = lcTableStr+THIS.mergetext(lcStr2)
ELSE
lcHTML = lcHTML + THIS.mergetext(lcStr2)
ENDIF
ENDIF
IF llTableRec
oResponse.Write(lcHTML+[])
oResponse.Flush
ENDIF
ENDIF
ENDFOR
IF llTableRec
oResponse.Write([</BODY></HTML>])
ELSE
lcHTML=THIS.mergetext(lcDivStart)+lcHTML+""+THIS.mergetext(lcDivEnd)
lcHTMLtable =STUFF(lcHTMLtable, lnAtPos1, lnAtPos2 - lnAtPos1+;
LEN(lcTableTag)+9, lcHTML)
IF llpagenumbers
lcPages=''
IF lnTotPages > 1
lngroupnumber = ceiling(START/lnpagenumbers)
FOR lnZ = lngroupnumber*lnpagenumbers-(lnpagenumbers-1) TO IIF(lnTotpages<lngroupnumber*lnpagenumbers,lnTotPages,lngroupnumber*lnpagenumbers) &&lnTotPages
IF lnZ=START
lcPages=lcPages+[ ]+ALLTRIM(STR(lnZ))+[ ]+crlf
ELSE
lcPages=lcPages+[

Read the full discussion online.

To add a post to this discussion, reply to this email (activevfp@discussions.codeplex.com)

To start a new discussion for this project, email activevfp@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com