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.

  • What is the actual content of Dep_listToShow[department]? How does the output differ from the objective? – David Reed Jun 19 '18 at 13:55
  • value will be stored like {"department1" : [1,2,3,4,5,6] , "department2" : [1,2,3]} something like this – patelkiran3090 Jun 19 '18 at 13:56
  • value will be the list of integers. – patelkiran3090 Jun 19 '18 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 Jun 19 '18 at 13:58
  • just edited for what output i want from list of integer in the map. – patelkiran3090 Jun 19 '18 at 14:00
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-

  • 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.. – patelkiran3090 Jun 20 '18 at 5:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.