I am trying to use the below wrapper class in VF page as this class should return me record from Child Account and Address objects. However, I am unable to get it right. Please find the class below.
Please note - the condition WHERE Child_Account__c ='0017E00000FZqdVQAT'
is used only for debugging purpose and I am expecting the list to return multiple rows.
In VF I'm trying to use :
<apex:repeat value="{!WrapperList}" var="xx" >
But VF is showing error Unknown property ....WrapperList.
public without sharing class AffiliationWrapperClass {
public List < AffiliationWrapper > WrapperList {get;set;}
List < Child_Account__c > cAcList = new List < Child_Account__c > ();
Set < Id > pAcId = new Set < Id > ();
public AffiliationWrapperClass() {
for (Child_Account__c cAc: [SELECT Name, OK_Role__c, Parent_Account__c, Work_Status_AGN__c,
Parent_Account_vod__r.Beds__c, Parent_Account_vod__r.Name,
Child_Account__c, Copy_Address__c, Network_Primary__c
FROM Child_Account__c
WHERE Child_Account__c = '0017E00000FZqdVQAT'
]) // filter with child acc
{
cAcList.add(cAc);
pAcId.add(cAc.Parent_Account__c);
}
Map < Id, Address__c > addrMap = new Map < Id, Address__c > ([select Account__c, Name from Address__c
WHERE Account__c IN: pAcId
]); // filter with child's parent acc
for (Child_Account__c ca: cAcList) {
WrapperList.add(New AffiliationWrapper(ca, addrMap.get(ca.Parent_Account__c)));
}
}
Public Class AffiliationWrapper {
Child_Account__c accObj;
String fullAddress;
Public AffiliationWrapper(Child_Account__c accRec, Address__c addr) {
accObj = accRec;
fullAddress = addr.Name;
}
}
}