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
Sami CohenSami Cohen 

Paging-Problem

Here is my VisualPage code:
 
Code:
<apex:page controller="testConCTRL">
<apex:form >
<apex:pageBlock >
        <apex:dataTable value="{!LIST}" var="Prod" >            
            <apex:column value="{!Prod.Name}">
            </apex:column>                 
        </apex:dataTable>               
                  
        <apex:commandButton value="next" action="{!setcon.next}" ></apex:commandButton> 
        <apex:commandButton value="previous" action="{!setcon.previous}" ></apex:commandButton>   
</apex:pageBlock>
</apex:form>
</apex:page>

 Here is my Controller:
Code:
public class testConCTRL {

List<Product2> p = new List<Product2>();


public ApexPages.StandardSetController setCon {

get {

if(setCon == null) {
setCon = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, Name FROM Product2]));
setcon.setpageSize(5);
}

return setCon;

}

set;

}
public List<Product2> getLIST() 
{
    p= new List<Product2>();
    p = (List<Product2>) setCon.getRecords();
    return p;
}

}

 I have 2 problems:
  • The getRecords() actions return just 4 entries although I have more than 10 entries in my Product2 object.  
  • The next() action returns the same result everytime.

Help would be appreciated.



Saurabh DhobleSaurabh Dhoble

Checkout this post