I have a list of accounts and i need to also have a ability to remove records from this list.
Now this list sometimes gets in a lot of records which causes the page to reach the heap size limit. To get rid of the heap size issue i was thinking of using the standard set controller with pagination so that we dont get a huge heap size.
Now i know that the list of accounts would not hold huge no of records. But i loose the ability to remove the records from the list. I am currently using command link against each record to remove the record from the list.
<apex:commandLink value="Remove" action="{!remove}" reRender="resultTable" immediate="true">
<!-- this param is how we send an argument to the controller, so it knows which row we clicked 'remove' on -->
<apex:param value="{!s.Id}" assignTo="{!toUnselect}" name="toUnselect"/>
</apex:commandLink>
The remove method in controller SearchResult is the List of the account.
public pageReference remove()
{
Integer count = 0;
system.debug('to unselect is ' + toUnselect);
for(Account d : searchResult){
system.debug('to unselect and d.Id is ' + d.Id + ' ' + toUnselect);
if((String)d.Id==toUnselect){
system.debug('Found a match');
removedIds.add(toUnselect);
searchResult.remove(count);
break;
}
count++;
}
If i were to use the standard set controller
List<account> searchResult= [SELECT Name FROM Account LIMIT 200];
ApexPages.StandardSetController con = new ApexPages.StandardSetController(searchResult);
i can pass the big list into the into setcontroller and pass from the setcontroller into smaller list by using con.getRecords() method.
How should i modify the remove method so that my list should not hold any of the removed records if i traverse to and fro through different pages.