I have a problem with making a dynamic table component that displays selected sObject fields with specified header values. The very first idea was to supply the component with an apex:attrubite of type Map, containing a key-value pairs for column headerValue and sObject field name correspondingly. Then use apex:repeat to iterate through the collection and add appropriate headers and apex:outputField just like that:


<apex:attribute name="collection" description="..." type="sObject[]" assignTo="{!sObjectCollection}"/>
<apex:attribute name="fields" description="..." type="Map<String,String>" assignTo="{!fieldsMap}"/>

<apex:pageBlockTable value="{!sObjectsCollection}" var="collectionItem">
    <apex:repeat value="{!fieldsMap.keySet()}" var="key">
        <apex:column headerValue="{!key}">
            <apex:outputField value="{!collectionItem.get(fieldsMap.get(key)}"/>


public List<sObject> sObjectsCollection{ get; set; }
public Map<String, String> fieldsMap { get; set; }

But I get the error: Unsupported type Map<String,String> encountered. I'm sure there is some better approach to get desired result.

I have also tried to get the headerValues from one String and the field names from another but then I don't know how to assign a proper headerValue to specific field name. Any ideas?


2 Answers 2


from the Visualforce Developer’s Guide

Maps, specified using type="map". You don't need to specify the map's specific data type.

Have you tried this ?

  • Yes, I have tried this as well. I have found a better approach to make this dynamic table and I will update my post as soon as I finish implementing it. Jul 29, 2015 at 16:56

Accepting maps in Components is unfortunately unsupported. Setting the type to simply Map will not cause the Component to actually accept Maps so we can just as well consider that option to be non-existent.

You'll have to create a wrapper class around your Map, then use that wrapper class as the Type in your apex:attribute and pass your map around like that.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .