• #20495
    Salesforce | Vishant Vishant #217
    Forcetalks

    How can i  display records of account, contacts, opty on the same Salesforce Visualforce page and then process the selected records using wrapper class?

    How can i  display records of account, contacts, opty on the same VF page and then process the selected records using wrapper class??

    please explain it in detail (the exact working of wrapper class)

    Tagged: , , , , ,

    #20496
    Salesforce | Shaharyar Shaharyar #9
    Forcetalks

    /*VISUAL FORCE PAGE AND CONTROLLER WITH WRAPPER CLASS*/

    <apex:page controller=”MultipleContact” sidebar=”false”>
    <apex:form >
    <apex:pageBlock >
    <apex:pageBlockTable value=”{!listContact}” var=”cnct” id=”ref”>
    <apex:column headervalue=”Last Name”>
    <apex:inputfield value=”{!cnct.con.LastName}”/>
    </apex:column>
    <apex:column headervalue=”First Number”>
    <apex:inputfield value=”{!cnct.con.FirstName}”/>
    </apex:column>
    <apex:column headervalue=”Email”>
    <apex:inputfield value=”{!cnct.con.Email}”/>
    </apex:column>
    <apex:column headervalue=”Title”>
    <apex:inputfield value=”{!cnct.con.title}”/>
    </apex:column>
    <apex:column headervalue=”RemoveContact”>
    <apex:inputCheckbox value=”{!cnct.isSelected}”/>
    </apex:column>
    </apex:pageBlockTable>
    <apex:pageblockbuttons >
    <apex:commandButton value=”Add More Contact” action=”{!addContact}” reRender=”ref” />
    <apex:commandButton value=”Save Contact” action=”{!SaveContact}”/>
    <apex:commandButton value=”Remove Contact” action=”{!RemoveContact}”/>
    </apex:pageblockbuttons>
    </apex:pageBlock>
    </apex:form>
    </apex:page>
    public class MultipleContact{

    public list<cContact> listContact{get;set;}
    public MultipleContact(){ //constructor
    listContact=new list<cContact>();
    listContact.add(new cContact(new contact()));
    }
    public void addContact() {
    Contact cnct = new Contact();
    MultipleContact.cContact cn = new MultipleContact.cContact(cnct);
    listContact.add(cn);
    }
    public pagereference saveContact(){
    List<Contact> myList = new List<Contact>();
    for(cContact c : listContact){
    myList.add(c.con);
    }
    pagereference pg=new pagereference(‘/003/o’);
    insert myList;
    return pg;
    }
    public pageReference RemoveContact() {
    List<cContact> li = listContact;
    for(Integer i=0 ; i<li.size(); i++){
    if(li[i].isSelected == true){
    listContact.remove(i);
    }
    }
    pageReference pg1=new pageReference(‘/’);
    //delete listContact;
    return null;
    }
    //Inner class of contact
    public class cContact{
    public Contact con{get;set;}
    public boolean isSelected{get;set;}
    public cContact(Contact con){
    this.con = con;
    isSelected = false;
    }
    }

    }

    #20497
    Salesforce | Vishant Vishant #217
    Forcetalks

    Actually i have to deal with all three of them(Account,contact,opportunity) on the same VF page and after selection particular records i want them to get displayed on a new page block

Viewing 3 posts - 1 through 3 (of 3 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Property of Forcetalks.com
Copyright 2017 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?