+ Start a Discussion
jtwoods4jtwoods4 

Display Array returned by Controller

My controller class is returning an array of string to my apex page. How do I loop over the array items and display them?

 

In the code below I am just trying to access the first index in the array and display the value. But this does not work.

 

<apex:page standardController="Account" extensions="RECALLFDMServiceController">

<h1>TTM Revenues</h1>
    <apex:pageBlock >
        <apex:pageblocktable value="{!TTMByListBillingID}" var="TTMResponse">            


          <apex:column >
                {!TTMResponse['0'].TTM}
            </apex:column>

 

        </apex:pageblocktable>
    </apex:pageBlock>
    
</apex:page>

 

Best Answer chosen by Admin (Salesforce Developers) 
SeAlVaSeAlVa

What about ...

 

<apex:page standardController="Account" extensions="RECALLFDMServiceController">

<h1>TTM Revenues</h1>
    <apex:pageBlock >
        <apex:pageblocktable value="{!TTMByListBillingID}" var="TTMRevenues">            
            <apex:column HeaderValue="Key" value="{!TTMRevenues}"/>
            <apex:column headerValue="Value" value="{!TTMByListBillingID[TTMRevenues]}"/>
        </apex:pageblocktable>
    </apex:pageBlock>
    
</apex:page>

 Regards

All Answers

SeAlVaSeAlVa

To iterate, try the following

 

<apex:page standardController="Account" extensions="RECALLFDMServiceController">
    <h1>TTM Revenues</h1>
    <apex:pageBlock >
        <apex:pageblocktable value="{!TTMByListBillingID}" var="TTMResponse">            
            <apex:repeat value="{!TTMresponse}" var="TTMR">
                <apex:column value="{!TTMR.TTM}" />
            </apex:repeat>
        </apex:pageblocktable>
    </apex:pageBlock>
</apex:page>

 Regards

jtwoods4jtwoods4

 

Thank you for the response.

 

I am sorry I made a mistake. My controller method is actually returning a map<string,string>

 

I need to display the map in a table on my visual force page. Why is this so difficult?

 

In my code below the pageblocktable calls my controlle rmethod getTTMByListBillingID. This method returns a map<string,string>. There are several key value pairs in the returned map<string,string>. I just need to display this.

 

<apex:page standardController="Account" extensions="RECALLFDMServiceController">

<h1>TTM Revenues</h1>
    <apex:pageBlock >
        <apex:pageblocktable value="{!TTMByListBillingID}" var="TTMRevenues">            
        
          DISPLAY THE KEY VALUES IN THE MAP HERE
          
        </apex:pageblocktable>

    </apex:pageBlock>
    
</apex:page>

 

 

 

 

 

 

 

SeAlVaSeAlVa

What about ...

 

<apex:page standardController="Account" extensions="RECALLFDMServiceController">

<h1>TTM Revenues</h1>
    <apex:pageBlock >
        <apex:pageblocktable value="{!TTMByListBillingID}" var="TTMRevenues">            
            <apex:column HeaderValue="Key" value="{!TTMRevenues}"/>
            <apex:column headerValue="Value" value="{!TTMByListBillingID[TTMRevenues]}"/>
        </apex:pageblocktable>
    </apex:pageBlock>
    
</apex:page>

 Regards

This was selected as the best answer
jtwoods4jtwoods4

Excellent! Now I just need to make it repeat for every key value pair in the map