1

I am getting the value of map<string,map<map<string,string>,string>> for controller. I need to iterate and display the value in vf page, But I am not getting the output.

<apex:page showHeader="true" controller="DealerReport">
    <apex:form>
        <table>
            <tr>
                <apex:repeat value="{!map}" var="fieldKey">
                    key: {!fieldKey }
                    value: {!map[fieldKey]}
                    <apex:variable var="c" value="{!map[fieldKey]}" />
                    {!map[fieldKey][c]}
                </apex:repeat>  
            </tr>
        </table>    
    </apex:form>
</apex:page>

smaple map: map<productType,map<map<name,size>,quantity>>

{Flowers={{rose=20cm}=10pcs}}

  • Can you post sample value of your map map<string,map<map<string,string>,string>> – Reshma Mar 11 at 9:06
  • {Flowers={{rose=20cm}=10pcs}} – Manjushree D Mar 11 at 9:13
1

You won't be able to display that kind of a Map as in one of your inner Map you are having a complex type i.e. Map (i.e. in 2nd Map where you have Map of string,string) as key which cannot be sorted and hence, you won't be able to display in visualforce page using a straight forward approach.

Looking at the example you have provided, you can use Map<string,Map<string, Map<string,string>>> instead of Map<string,Map<Map<string,string>,string>>. So as per your example, you can have your data like {Flowers={rose= {20cm=10pcs}}} instead of {Flowers={{rose=20cm}=10pcs}}.

Having the data in the above format will make your visualforce page much simpler and you can show the data using this below code

Note : You will have to change the datatype to Map<string,Map<string, Map<string,string>>> and have the data in this format {Flowers={rose= {20cm=10pcs}}}, only then you would be able to use this below visualforce code.

<apex:repeat value="{!map}" var="fieldKey1">
    key1: {!fieldKey1}
    value1: {!map[fieldKey1]}
    <br/>
    <apex:repeat value="{!map[fieldKey1]}" var="fieldKey2">
        key1: {!fieldKey2}
        value1: {!map[fieldKey1][fieldKey2]}
        <br/>
        <apex:repeat value="{!map[fieldKey1][fieldKey2]}" var="fieldKey3">
            key1: {!fieldKey3}
            value1: {!map[fieldKey1][fieldKey2][fieldKey3]}
            <br/>
        </apex:repeat>
    </apex:repeat>
</apex:repeat>
0

The declaration format you are using map<string,map<map<string,string>,string>> is not right. using map as a key in the map is not the right approach because keys can not be sorted. you should use map in below format and arrange your data accordingly.

Map<string,Map<string,Map<string,string>>>

Please mark this answer selected if it helped.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.