Parent with child records in same page

VF:
-----
<apex:page controller="WrapperClassForAccountAndRelatedContacts" sidebar="false"  standardStylesheets="false">
     <apex:form >                   
            <apex:pageblock >             
             <apex:repeat value="{!AccountsCons}" var="EAcc">
                   <apex:pageBlockSection title="{!EAcc.wrapAcct.name}" collapsible="true">
                       <apex:pageBlockTable value="{!EAcc.wrapCon}" var="Econ">
                            <apex:column >                               
                              <apex:outputField value="{!Econ.Name}" />                   
                            </apex:Column>                            
                            <apex:column >
                                <apex:outputField value="{!Econ.Phone}" />
                            </apex:Column>  
                            <apex:column >
                                <apex:outputField value="{!Econ.Email}" />
                            </apex:Column>                                      
                        </apex:pageBlockTable>                       
                   </apex:pageBlockSection>
                </apex:repeat>              
            </apex:pageblock>
         </apex:form>       
</apex:page>

Class :
-------

public with sharing class WrapperClassForAccountAndRelatedContacts{     public list<Account> lstAcc{get;set;}     public List<Contact> conList{get;set;}     public List<AccountWrapper> acctCon{get;set;}     public WrapperClassForAccountAndRelatedContacts(){         lstAcc = new list<Account>();         lstAcc = [select id,name,(select id,lastname,phone,Name,firstname,email from Contacts),phone from Account];                       conList = new  List<Contact>();         for(Account acc : lstAcc){            conList = acc.contacts;         }     }          public List<AccountWrapper> getAccountsCons(){      acctCon = new List<AccountWrapper>();      for(Account acct : lstAcc){         acctCon.add(new AccountWrapper(acct,acct.Contacts));                 }          return acctCon;     }         public class AccountWrapper{             public Account wrapAcct {get;set;}         public List<Contact> wrapCon {get;set;}         public AccountWrapper(Account acct, List<Contact> con){             this.wrapAcct =acct;             this.wrapCon = con;             }     }     } Screenshot : ------------

No comments:

Featured

What is Cryptography in salesforce and what are all the algorithms provided by them ?

A). It is a security protocal between two systems. Lets say we are integration two systems without any encrytion mechanism then hackers wil...

Popular