function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Purushottam Dank 1Purushottam Dank 1 

Its urgent , help guys

Hi , i have created i a VF page to add contacts but but the new requiment is have to put checkbox and delete checked records ???? 
i dont know how to solve but i just know i have to write Wrapper class m posting what i have done VF page lighting and Controller class ....
plz tell what should i do and what corrections i have to do in my code .... if possible post correct the code .... 

thanks in advance ... 
my controller and class ...

VF page lighting:
<apex:page StandardController="Contact" recordSetVar="contacts" tabStyle="Contact" extensions="MultiAdd"  id="thePage" >
    <apex:pageBlock title="Manage " mode="edit">
<apex:form >
    <apex:slds /> 
<apex:pageblock id="pb" >
    <apex:pageBlockButtons >
        <apex:commandbutton value="Add" action="{!Add}" rerender="pb1"/>
        <apex:commandbutton value="Save" action="{!Save}"/>
        <apex:commandbutton value="Cancel" action="{!Cancel}"/>
        
        </apex:pageBlockButtons>
    <apex:pageblock id="pb1">
          <apex:repeat value="{!lstInner}" var="e1" id="therepeat">
                <apex:panelGrid columns="6">
                    <apex:panelGrid headerClass="Name">
                        
                    <apex:facet name="header">Del</apex:facet>
                        
                        <apex:commandButton value="X" action="{!Del}" rerender="pb1" immediate="true"> -->
                        <apex:param name="rowToBeDeleted" value="{!e1.recCount}" assignTo="{!selectedRowIndex}"></apex:param>
                   <!-- </apex:commandButton> 
                </apex:panelGrid>
                <apex:panelGrid >
                    <apex:facet name="header">FirstName</apex:facet>
                    <apex:inputfield value="{!e1.Cont.FirstName}"/>
                </apex:panelGrid>
                <apex:panelGrid >
                    <apex:facet name="header">LastName</apex:facet>
                    <apex:inputfield value="{!e1.Cont.LastName}"/>
                </apex:panelGrid>
                <apex:panelGrid >
                    <apex:facet name="header">Email</apex:facet>
                    <apex:inputfield value="{!e1.Cont.Email}"/>
                </apex:panelGrid>
                <apex:panelGrid >
                    <apex:facet name="header">Age</apex:facet>
                    <apex:inputfield value="{!e1.Cont.age__c}"/>
                </apex:panelGrid>
                <apex:panelGrid >
                    <apex:facet name="header">Mobile</apex:facet>
                    <apex:inputfield value="{!e1.Cont.MobilePhone}"/> 
                </apex:panelGrid>
            </apex:panelGrid>
              </apex:repeat>
            </apex:pageblock>
    </apex:pageblock>
        </apex:form>
    </apex:pageBlock>
</apex:page>

controller:
public class MultiAdd
{
    
    //will hold the account records to be saved
    public List<Contact> LstCont  = new List<Contact>();
    
    //list of the inner class
    public List<innerClass> LstInner 
    {  get;set; }
    
    //will indicate the row to be deleted
    public String selectedRowIndex
    {  get;set; }  
    
    //no. of rows added/records in the inner class list
    public Integer count = 1;
    //{  get;set;  }    
    
    
    ////save the records by adding the elements in the inner class list to lstAcct,return to the same page
    public PageReference Save()
    {
        system.debug('Save Called');
        PageReference pr = new PageReference('/apex/MultiAdd');
        
        for(Integer j = 0;j<lstInner.size();j++)
        {
            LstCont.add(LstInner[j].Cont);
        } 
        insert LstCont;
        pr.setRedirect(True);
        return pr;
    }
        
    //add one more row
    public void Add()
    {  
        system.debug('Add Called');
        count = count+1;
        addMore();      
    }
    
    /*Begin addMore*/
    public void addMore()
    {
        //call to the iner class constructor
        innerClass objInnerClass = new innerClass(count);
        
        //add the record to the inner class list
        LstInner.add(objInnerClass);
        system.debug('Add More Called');
       // system.debug('lstInner---->'+lstInner);            
    }/* end addMore*/
    
    /* begin delete */
    public void Del()
    {
        system.debug('Delete Called');
        system.debug('selected row index---->'+selectedRowIndex);
        lstInner.remove(Integer.valueOf(selectedRowIndex)-1);
        count = count - 1;
        
    }/*End del*/
    /* Wrapper class 
    public class sObjectWrapper
    {
        public boolean isSelected{get;set;}  
        public Contact myContact{get;set;}  
        public sObjectWrapper(Contact myContact,Boolean isSelected){  
        this. myContact = myContact;  
        this.isSelected = isSelected;  
    }  
 }  */
    
    
    
    /*Constructor*/
    public MultiAdd(ApexPages.StandardsetController ctlr)
    {
        system.debug(' Called MultiAdd Constructor');
        LstInner = new List<innerClass>();
       // addMore();
        selectedRowIndex = '0';
        
    }/*End Constructor*/
        


    /*Inner Class*/
    public class innerClass
    {       
        /*recCount acts as a index for a row. This will be helpful to identify the row to be deleted */
        public String recCount
        { get;set;}
        
        
        public Contact Cont 
        { get;set;}
        
        /*Inner Class Constructor*/
        public innerClass(Integer intCount)
        {
           // System.debug('');
            recCount = String.valueOf(intCount);        
            
            /*create a new Contact*/
            Cont = new Contact();
            
        }/*End Inner class Constructor*/    
    }/*End inner Class*/
}/*End Class*/