1

Can anyone explain to me why the readOnly="true" attribute is not working as expected? I'm attempting to display a list of 5,000 records using an <apex:repeat> tag, and I'm receiving an error:

Collection size 5,000 exceeds maximum size of 1,000.

Code examples are below, but this should be working, as Salesforce documentation suggests:

the readOnly attribute also increases the maximum number of items in a collection that can be iterated over using components such as <apex:dataTable>, <apex:dataList>, and <apex:repeat>. This limit increased from 1,000 items to 10,000.

Controller Logic:

public List<Integer> bulkTest {get; set;}

bulkTest = new List<Integer>();
for ( Integer i = 0; i < 5000; i++){
    bulkTest.add(i);
}

Visualforce Page:

<apex:page controller="Bulk_Controller" readOnly="true">

    <apex:repeat value="{!bulkTest}" var="int" >
        <apex:outputText value="{!int}" />
    </apex:repeat>

</apex:page>
5
  • it is working perfect in my dev org..
    – Ratan Paul
    Commented May 26, 2016 at 17:41
  • 1
    As it works for me. What api version do you use? Can you please add whole controller to op. Commented May 26, 2016 at 17:45
  • Have you tried to set the @ReadOnly in your controller as well? Commented May 26, 2016 at 18:19
  • After posting, I realized that this code example works as expected on its own, but the same exact code pasted into our actual controller is failing. Commented May 26, 2016 at 18:50
  • @IlyaLepesh The controller itself is ~1500 lines of code, but there's no overlap between the Bulk Test and the actual controller logic. It's being called by a Command Link/Command Button on different pages when the fails. API is 36. Commented May 26, 2016 at 19:28

2 Answers 2

1

Turns out there's some strange behavior on ReadOnly in my use case.

If the PREVIOUS page was not marked as ReadOnly, the CURRENT page was not allowing me to retrieve more than 1,000 records. Adding a ReadOnly page with nothing but a OnLoad Javascript method, which calls an ActionFunction to take me to the next page fixes everything.

0

You can't iterate over a thousand records.

While the limit of 1000 items in collections was relaxed in Spring '10, there is still a limit of 1000 items that can be iterated over in VF pages. Generaly speaking, when displaying large collections to users, you should aim to paginate such large data sets. Part of this is just good UI design. The other part has to do with us needing to protect the infrastructure from having to render potentially huge pages.

From here: https://developer.salesforce.com/forums?id=906F0000000964gIAA

1
  • That link is from 2010 and the current Developer Guide directly contradicts it. Commented May 27, 2016 at 17:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .