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
Ratheven SivarajahRatheven Sivarajah 

Return a a list from a controller and use it in a VF page

Hey I was able to do a SOQL and store it in a list. How do I return it and use it in my VF page. Thank you in advance

Controller:
public with sharing class TechnologyProduct {

    public TechnologyProduct() {
     List <Technology_Product__c> result = [SELECT Id, Name FROM Technology_Product__c where Account__c='00105000002oNIyAAM']; 
    }   
}
Best Answer chosen by Ratheven Sivarajah
Shri RajShri Raj
To return the list from the controller, you can add a getter method to return the list. In the Visualforce page, you can reference the getter method to display the data
 
public with sharing class TechnologyProduct {
    public List < Technology_Product__c> result {get; set;} 
    public TechnologyProduct() {
        result = [SELECT Id, Name FROM Technology_Product__c where Account__c='00105000002oNIyAAM']; 
    }   
}
 
<apex:page controller="TechnologyProduct">
    <apex:repeat value="{!result}" var="product">
        <p>{!product.Name}</p>
    </apex:repeat>
</apex:page>