+ 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(){
    qwerty=slw1.size();
    qualifyindex= ApexPages.currentPage().getParameters().get('indexnumber'); 
    integer countq=integer.valueof(qualifyindex);
    system.debug('----->qualifyindex'+qualifyindex);
      system.debug('----->countq'+countq);
      
    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 ;
        sl.indexqualify=slw1[countq].indexqualify+1;
        integer inq=slw1[countq].indexqualify+1;
       
        for(steplibrarywrap  slw:slw1){
            if(slw.indexqualify>=inq){
            slw.indexqualify=inq+1;
            }
          } 
       slw1.add(countq,sl);
       listcatteria.addall(slw1);
    system.debug('------>listcatteria'+listcatteria);
    
    }










User-added image