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
Priyesh Misquith 12Priyesh Misquith 12 

passing map values from apex to vf component

I need help on the following scenario
I have map Map<Id , list<sObject>> getMymap()

which returns data in followig format.
 
{a71w0000000bnoJAAY=(CustomObject1__c:{Id=aGY3L00000000UOWAY, field1__c=Hurray, Field2__c=Hello, Field3__c=a71w0000000bnoJAAY, CurrencyIsoCode=USD}, CustomObject2__c:{Id=a6W3L0000006CFlUAM, Field4__c=a6a3L000000008xQAA, Field5__c=a71w0000000bnoJAAY, Field6__c=Salesforce, Field7__c=2, Field8__c=59.00, Field9__c=118.00, Field10__c=EUR}),
 a71w0000000bnoMAAY=(CustomObject1__c:{Id=aGY3L00000000GsWAI, field1__c=Hurray, Field2__c=Hello, Field3__c=a71w0000000bnoMAAY, CurrencyIsoCode=USD}, CustomObject2__c:{Id=a6W3L0000005CFkUAM, Field4__c=a6a3L000000008xQAA, Field5__c=a71w0000000bnoMAAY, Field6__c=Visualforce, Field8__c=2, ccrz__Price__c=95.00, Field9__c=190.00, Field10__c=EUR})}

I have the apex page.
<apex:page controller="Account" extensions="otherclass1">
< c:someComponent />
</apex:page>
 
 I want to pass this data to visualforce component and populate the populate in the table.
 (this Key does not belong to account but these are the common id  in CustomObject1__r.a71w0000000bnoJAAY and CustomObject2__r.Field5__c)
Dushyant SonwarDushyant Sonwar
Priyesh ,

You need to do some modification in your vf component .

I am creating one column table with data, if you need more columns you can add more td and bind more fields
<apex:component>
  <apex:attribute name="mapOfData" description="test" access="Public" type="Map"/>
  
    <table>
        <apex:repeat value="{!mapOfData}" var="item" >

        <tr>
             <td>      <apex:outputText value="{!mapOfData[item].field1__c}" /></td>
        </tr>
        </apex:repeat> 
    </table>  
</apex:component>
 
<apex:page controller="Account" extensions="otherclass1">
< c:someComponent  mapOfData="{!mainMap}"/> 
</apex:page>
Hope this helps!
 
Priyesh Misquith 12Priyesh Misquith 12
Hi Dushyant,

I am getting below error Wrong type for attribute <c:someComponent  mapOfData="{!mainMap}">. Expected Map, found Map<Id,List<SObject>>