function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Starz26Starz26 

Possible bug in StandardSetController setPageNumber

if I call

 

var.setPageNumber(integer.valueOf(ApexPages.CurrentPage().getParameters().get('pgNum')));

 

IT ALWAYS sets the pagenumber to 1 regardless of what the apexPages parameter

 

If I However do:

 

Public Integer tstPg = integer.valueOf(ApexPages.CurrentPage().getParameters().get('pgNum')));

var.setPageNumber(txtPg);

 

it sets the page just fine no matter what the ApexPage Parameter is. If it is 2, the page is set to 2

 

Any one have any ideas?

 

Scott.MScott.M

I've had this happen if I haven't set the PageSize. 

 

 

 

cropzimcropzim
I can definitely confirm Scott.M - you must do the calls in this order:
<pre>
ssc.setpageSize(somePgSize);
ssc.setpageNumber(somePgNumber);
</pre>
This makes sense in that without knowing the pageSize to apply to the ssc result list, the pageNumber is meaningless - That is, if pagesize = 20, setting pagenumber to 2 will start at record 21st in the list but if pageSize is unknown, what does pageNumber 2 mean?  Now, one could argue that these values should be order independent as it is the getRecords() method call that matters but the implementation does not appear to work this way. I've filed a request to have the doc updated
Venkat PolisettiVenkat Polisetti
Good catch! It helped me well. Thanks.