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
Kashona DotsonKashona Dotson 

How to call a field from a list on extension controller to visualforce page

I have a visualforce page referencing a standard controller and extension. On the extension controller, I have three lists. How do I reference the lists in my visualforce page so that I can display fields that the extension has queried? Do I need an additional variable in my page attributes? If so, how do I write it?
AnudeepAnudeep (Salesforce Developers) 
Hi Kashona, 

It is done in the same way as it is for a regular controller. See the below example. Although it is a map in the example, the same applies to Lists

Apex Controller
public with sharing class MapAccCont {
 
    Map<Integer, Account> mapToAccount = new Map<Integer, Account>();
 
    public MapAccCont() {
        Integer i = 0;
        for (Account a : [SELECT Id, Name FROM Account LIMIT 10]) {
            mapToAccount.put(i, a);
            i++;
        }
    }
 
    public Map<Integer, Account> getMapToAccount() {
        return mapToAccount;
    }
}

Visualforce Page
 
<apex:page controller="MapAccCont">
    <apex:form>
        <apex:repeat value="{!mapToAccount}" var="accNum">
            <apex:inputField value="{!mapToAccount[accNum].Name}" />
        </apex:repeat>
    </apex:form>
</apex:page>

See this documentation for more examples. Let me know if this helps

Thanks, 
Anudeep