0

I have a req. to map The URL that is stored in the field which holds the url of the image in the documents. In VF page I reference the field that will hold the url from the documents. So I created a Map Controller :

public List<List<String>> IORefFormatedDescriptions {get;set;}
IORefFormatedDescriptions = new List<List<String>>();
    Map<String,String> urlMap = new  Map<String,String>();

        NewsXtendIORef__c[] campEles = [Select id, Name, Campaign_Element__c, Details__c, Quantity__c, Display_Order__c, URL__c FROM NewsXtendIORef__c WHERE Campaign_Element__c In: IORefFormatedDescriptions];

        for(NewsXtendIORef__c eleId : campEles){
            urlMap.put(eleId,'');
            if(eleId.URL__c != null){
                urlMap.put(eleId, eleId.URL__c);
            }
        }

VF page :

<apex:variable var="i" value="{!0}" />
                <apex:repeat value="{!IORefFormatedDescriptions}" var="row">
                    <tr style="font-size:14px;background-color:#B0C4DE;">
                        <apex:repeat value="{!row}" var="column">
                            <td>{!column}
                            <apex:variable var="i" value="{!i+1}"/>

                            <apex:outputPanel rendered="{!IF((mod(i,2)) == 0,false,true)}" style="text-align:center;" ><br></br>
                             <img src="{!urlMap[column]}" style="width:10px; height:20px; align:middle;" />
                            </apex:outputPanel>
                            </td>
                        </apex:repeat>
                    </tr>
                </apex:repeat>

But I am getting the error because IORefFormatedDescriptions is List<List<String>>. How Can I iterate over this?

3
  • can you post more code of controller, for example, how IORefFormatedDescriptions is defined
    – kurunve
    Commented Aug 29, 2016 at 8:25
  • @kurunve I have edited the code
    – wizard
    Commented Aug 29, 2016 at 8:29
  • urlMap is of type Map<String,String>. But you are trying to insert NewsXtendIORef__c as map key. Isn't your controller showing any error while saving? Commented Aug 29, 2016 at 9:06

1 Answer 1

0

If you want to query where your field matches any of the String values in your List<List<String>>, you need to flatten your structure. Something like:

List<String> values = new List<String>();
for (List<String> subList : IORefFormatedDescriptions) values.addAll(subList);
List<MyObject__c> records = [SELECT Fields__c FROM MyOjbect__c WHERE Field IN :values];

You must log in to answer this question.

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