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
RossKRossK 

Maps with Collections - Collections are not correct on vf page

Hi
I am experiencing unexpected behavoir with a map that contains sets of strings. The controller is below:
 
public class testbogusmap {
    public map<string,set<string>> BogusMap {get{
         map<string,set<string>> ret = 
                  new map<string,set<string>>();
         set<string> hiSet = new set<String>();
         hiSet.add('ho');
         ret.put('hey',hiSet);   
        return ret; }
    } 
}


The VF page is here:

 
<apex:page controller="testbogusmap">
    {!bogusmap}
    </apex:page>
My VF page displays

{hey=common.apex.runtime.impl.SetValue@d08}

instead of {hey='ho'} which is what is displayed in the developer console.  Why is this?

Thank you!
 

 
jlhmitchelljlhmitchell
In order to display data contained in a map (or even in a list) in Visualforce, you need to iterate through the values. <apex:repeat> can help (as can <apex:datalist>, <apex:datatable>). This link is kind of old, but still valid, and it illustrates both list and map iteration http://blog.wdcigroup.net/2012/10/iterating-a-map-in-visualforce-page/

See if that helps.
RossKRossK
Thank you!