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
MiddhaMiddha 

Accessing Map values on Visualforce page

Hi,

 

A simple Visualforce question: What’s the quick and dirty way of getting a value of the values for keys of a Map from an APEX class?

 

Example – I need the value of the key ‘A’ on a Visaulforce page, from the following:

 

public Map<String,String>> getThings(){
  Map<String,String> opts = new Map<String,String>(){'A'=>'B'};
  return opts;
}

 

I tried accessing it on the page as {!opts.A}, which gives me an error "MapValue.A" does not exist.

 

Thanks,

GreatG

Ron HessRon Hess
i think you must write a getter for each key in the map that you wish to access in your visualforce page.
MiddhaMiddha
Hi Ron,

I did created a wrapper class, with getters/setters, and it worked as required.

Thanks :)
[GM]
dchasmandchasman
We do plan to provide native page formula support for maps and also access to length/size on collections - stay tuned for when that will be released.
Chirag MehtaChirag Mehta

Hey,

 

Can you please post the wrapper and the getter/setter methods.  

sw6sw6

Hey I think this link here might help you in terms of the setters/getters.