+ Start a Discussion
Ramin MohammadiRamin Mohammadi 

displaying a map in an account VF page


I have this controller extension that is supposed to yield a map in the form of <Account, List<Installed_Products__c (child object of account)>>.

I need my VF page to essentially display

Account.Name                                  Installed_Product__c.Field
​Account.Name                                  Installed_Product__c.Field
​Account.Name                                  Installed_Product__c.Field

I tried using Apex:Repeat but get a Unknown property Account standard controller.

What is the form for doing so?


​public with sharing class whitespace{
transient public String AccountID{get;set;}
transient public String PAccountID{get;set;}
transient public List<Account>TIPlist{get;set;}
transient public String t{get;set;}
transient Map<Account,List<Installed_Products__c>> IPList{get;set;}
transient public Account Account_Name {get;set;}
transient public list<Installed_Products__c> P{get;set;}

public whitespace(ApexPages.StandardController controller){
    public Map<Account,List<Installed_Products__c>> IPListM(){
            AccountID = ApexPages.currentPage().getParameters().get('id');
            PAccountID = [select ParentId from Account where ID = :AccountID].ParentId;
            if (PAccountID == null){
                TIPList = [select Name,(select Product_Family__c from Product_Releases_del__r ORDER BY Product_Family__c ASC) from Account a where ParentID =: AccountID];
            else {
                TIPList = [select Name,(select  Product_Family__c from Product_Releases_del__r ORDER BY Product_Family__c ASC) from Account a  where ParentID =: PAccountID];   
            Map<Account,List<Installed_Products__c>> IPList = new Map<Account,List<Installed_Products__c>>();
            List <Installed_Products__c> P = new List<Installed_Products__c>{};
            for(integer j = 0; j < TIPList.size(); j++){ 
                t = '';
                Account_Name = TIPList[j];
                for(Integer i = (TIPList[j].Product_Releases_del__r.size()-1) ; i >= 0; i--){
                    Installed_Products__c x = TIPList.get(j).Product_Releases_del__r.get(i);
                    if(t == x.Product_Family__c){
                        system.debug('==='+ TIPList.get(j).Product_Releases_del__r.get(i));
                        system.debug(TIPList[j].Product_Releases_del__r) ;
                        system.debug('=== go');
                        t = x.Product_Family__c;
                IPList.put(Account_Name, P);   
        return IPList;
NagaNaga (Salesforce Developers) 
Hi Ramim,

I would first suggest cutting down your VF markup to the bare minimum until you get the rendered structure that you are trying to achieve. This will keep you from troubleshooting both the rendering from nested maps and related VF oddities (like nested pageblocktable header facets and rendering dynamic header text within the 2nd level).

Also if you don't need to maintain an explicit order of data output while rendering from the maps, you might look into using the keyset instead of an ancillary list of keys. If order is critical, lists are the way to go.

Since your example doesn't provide actual data structures being used nor specific expected data output, I mocked some up. This code is functional, the first VF pageblock outputs UL and LI tags, second outputs pageblocktable markup.

Please see the link below


Best Regards
Naga Kiran