You need to sign in to do that
Don't have an account?

Can Map collection be Apex:Repeat tag 's value ?
Good day,
Can i know if Apex:Repeat tag's value able hold Map instead of List ?
VF page
------------
<apex:repeat value="{!partnerFieldList}" var="field">
<apex:variable var="currentLabel" value="{!$Label.first_name}" rendered="{field.containsKey('First_Name__c')}"/>
Controller
-----------
public Map<String,Boolean> partnerFieldList = new Map<String,Boolean>{
'First_Name__c' => TRUE
};
public Map<String,Boolean> getPartnerFieldList(){
return partnerFieldList;
}
I would like to rendered the 'firstname' variable if the field are calling, but i get "Unsupported type common.apex.runtime.impl.MapValue encountered."error when i run the apex page
Thank you !
Rather than attempting to use a Map as the backing value for the repeat, you would define a subclass encapsulating all the information required of an entry in the Map, and return a List of instances of the subclass.
E.g.
-- in controller
public List<PartnerFields> partnerFieldList = new List<PartnerFields>();
public List<PartnerFields> getPartnerFieldList()
{
PartnerFields pf=new PartnerFields();
pf.hasFirstName=true;
partnerFieldList.add(pf);
return partnerFieldList;
}
public class PartnerFields
{
public Boolean hasFirstName {get; set;}
}
-- in VF page
<apex:variable var="currentLabel" value="{!$Label.first_name}" rendered="{!field.hasFirstName}"/>
All Answers
Hi Naishadh,
Do you mind to provide me some sample what you means by subclass logic ?
Thank you !
Rather than attempting to use a Map as the backing value for the repeat, you would define a subclass encapsulating all the information required of an entry in the Map, and return a List of instances of the subclass.
E.g.
-- in controller
public List<PartnerFields> partnerFieldList = new List<PartnerFields>();
public List<PartnerFields> getPartnerFieldList()
{
PartnerFields pf=new PartnerFields();
pf.hasFirstName=true;
partnerFieldList.add(pf);
return partnerFieldList;
}
public class PartnerFields
{
public Boolean hasFirstName {get; set;}
}
-- in VF page
<apex:variable var="currentLabel" value="{!$Label.first_name}" rendered="{!field.hasFirstName}"/>
This is pathetic. Yet add another cheap work around to the big list of things that should just work out of the box.
Please vote to fix this here http://sites.force.com/ideaexchange/ideaView?c=09a30000000D9xt&id=08730000000IIn5AAG