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
Ramin MohammadiRamin Mohammadi 

displaying a map in an account VF page

All,

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
etc.

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

What is the form for doing so?

Code:

​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 = '';
                system.debug(t);
                Account_Name = TIPList[j];
                P.clear();
                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(i);
                        system.debug(TIPList[j].Product_Releases_del__r) ;
                        system.debug('=== go');
                    }
                    else{
                        P.add(TIPList[j].Product_Releases_del__r[i]);
                        t = x.Product_Family__c;
                    }
                }
                IPList.put(Account_Name, P);   
            }
            system.debug(TIPList);
            system.debug(IPList.keySet());
            system.debug(IPList.values());
        
        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

http://salesforce.stackexchange.com/questions/8667/displaying-a-mapstring-mapstring-object-in-visualforce-page

Best Regards
Naga Kiran