0

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.

10
  • What is the actual content of Dep_listToShow[department]? How does the output differ from the objective?
    – David Reed
    Commented Jun 19, 2018 at 13:55
  • value will be stored like {"department1" : [1,2,3,4,5,6] , "department2" : [1,2,3]} something like this Commented Jun 19, 2018 at 13:56
  • value will be the list of integers. Commented Jun 19, 2018 at 13:57
  • So your code appears to be producing the expected output. Can you edit the question to be specific about the problem?
    – David Reed
    Commented Jun 19, 2018 at 13:58
  • just edited for what output i want from list of integer in the map. Commented Jun 19, 2018 at 14:00

1 Answer 1

1

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-

1
  • oh yes, did the same but var name i took duplicate so may be thats why i was getting error just changed variable name and it worked.. thank you very much.. Commented Jun 20, 2018 at 5:46

You must log in to answer this question.

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