[SalesForce] Map of string and list of integer with apex repeat in visualforce page

i have one map as following :

public lisT<integer> testIntList{get;set;} 
public list<string> departmentsToShow{get;set;}
public map<string,List<Integer>> Dep_listToShow{get;set;}

which will show the integer list based on department name.

in visual force page when i write following :

<apex:repeat value="{!departmentsToShow}" var="department">
     <apex:repeat value=" {!testIntList}" var="IntVal">
                        {!IntVal} --
 </apex:repeat></apex:repeat>

its giving me following output : 1 — 2 — 3 — 4 — 5 — 6

tub when i write following :

<apex:repeat value="{!departmentsToShow}" var="department">
    <apex:repeat value=" {!Dep_listToShow[department]}" var="IntVal">
                        {!IntVal}
    </apex:repeat> </apex:repeat>

its giving me following output : [1, 2, 3, 4, 5, 6] but i need this output : 1 — 2 — 3 — 4 — 5 — 6

i want to loop the list of integer from map. how to do that?

thanks in advance.

Best Answer

Given that your controller is like this:

public List<String> departmentsList{get;set;} //eg. ['dep1', 'dep2', 'dep3']
public Map<String,List<Integer>> departmentsMap{get;set;} //eg. 'dep1'=>[1,2,3], 'dep2'=>[4,5,6]

And your page is:

<apex:repeat value="{!departmentsList}" var="department">
<apex:repeat value="{!departmentsMap[department]}" var="itemNo">
-{!itemNo}-
</apex:repeat>
<apex:repeat>

Output should be like: -1-2-3-4-5-6-

Related Topic