+ Start a Discussion
Nirmal ChristopherNirmal Christopher 

Update the Variable in a Wrapper class dynamically -Maintain the order of index number based on the list size

I have a  Wrapper list which  I used to display the contents in the visualforce page  The wrapper  list has a Index number (showed in screen shot next to the button) . On Clicking the button the index number is passed to find the exact position and clone the value inside the list and adds inside the list again and increments the index number to +1.It works fine until that. But the subsequent index position needs to get updated.

for example if the list contains 6 rows. I am hitting the button inside the third row a new record need to get inserted copying the 3rd row's values in the 4 th  row. Then 5,6,7 th rows index number also have to be incremented appropriately. slw1 is the list in need to add and display.

Copied the method below which will execute on click of the button.
public void addcountqualify(){
    qualifyindex= ApexPages.currentPage().getParameters().get('indexnumber'); 
    integer countq=integer.valueof(qualifyindex);
    steplibrarywrap sl=new steplibrarywrap();
        sl.stagenames =slw1[countq].stagenames;  
        sl.stepNames  =slw1[countq].stepNames;
        sl.RequiredByCandidate=slw1[countq]. RequiredByCandidate;
        sl.order = slw1[countq].order+'dupe' ;
        sl.StepLibrary =slw1[countq]. StepLibrary ;
        sl.evaluator =slw1[countq].evaluator ;                    
        sl.evaluatorName = slw1[countq].evaluatorName ;
        sl.StepLibraryID =slw1[countq].StepLibraryID ;
        integer inq=slw1[countq].indexqualify+1;
        for(steplibrarywrap  slw:slw1){

User-added image