I have a visualforce page with
<apex:commandButton value="Afficher" action="{!filterRecords}" reRender="table" immediate="true" />
in the constructor I have:
public RCS(){
counter = 0;
rcsList = new list<T13_REPART_CS__c>();
rcswrapperList = new list<rcswrapper>();
for(Integer i=0;i<10;i++){
rcswrapper rcsWrap = new rcswrapper(new T13_REPART_CS__c());
counter++;
rcsWrap.counterWrap = counter;
rcswrapperList.add(rcsWrap);
}
}
so I initially have 10 rows. When I click the button I want all rows to be deleted:
public PageReference filterRecords(){
Integer size = rcswrapperList.size();
for(Integer i=0;i<size;i++){
if(!rcswrapperList.isEmpty())
{ rcswrapperList.remove(i);
}
}
counter=0;
return null;
}
I get the following error: System.ListException: List index out of bounds: 5