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
Justin RuckJustin Ruck 

VF Table Showing Only Headers without Values

I have a table in a VisualForce page that is only showing headers.  I checked my controller, and there are values in the Sandbox for my query.  Is there anything you can see as to why the table isn't pulling in values?

VF Page:
 
<apex:page controller="HomeGamificationController">
    <apex:pageBlock title="Rank">
        <apex:pageBlockTable value="{!Top10List}" var="ar" rows="10" width="50%">  
            <apex:column headerValue="Owner">
                <apex:outputText value="{!OwnedBy}"/>
            </apex:column>
            <apex:column headervalue="Closed Amount">
                <apex:outputText value="{!Amount}"/>
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

APEX Class
 
public class HomeGamificationController 
{
    public list<AggregateResult> lstAR = new list<AggregateResult>();
    public list<oppClass> Top10List { get; private set; }
    private User currentUser { get; private set; }
    public String OwnedBy { get; private set; }
    public Double Amount { get; private set; }
    
    public HomeGamificationController()
        
        
    {
        //pulling the current user information
        this.currentUser = Database.query ('select Branch__c, BranchShort__c, RegionSGI__c, Country, ReportLevel__c, X2015_Collections_Budget__c from User where Id = \'' + UserInfo.getUserId() + '\' limit 1');
        
        //there are many different levels of users, with some seeing different data
        if (this.currentUser.ReportLevel__c == 'Territory Manager')
        {
            lstAR = [select Owned_By__c, sum(Amount) amt
                     from Opportunity
                     where Opportunity.Region_SGI__c = :this.currentUser.RegionSGI__c  and Close_Date_Current_Quarter__c = True and StageName = 'Closed Won'
                     group by Owned_By__c                                     
                     ORDER BY sum(Amount) ASC
                     LIMIT 10];
            for (AggregateResult ar : lstAR)
                System.debug(ar.get('owner')+'-'+ar.get('amt'));
        }
        
        
        
        else if (this.currentUser.ReportLevel__c == 'Market Manager')
        {
            lstAR = [select Owned_By__c, sum(Amount) amt
                     from Opportunity
                     where Opportunity.Region_SGI__c = :this.currentUser.RegionSGI__c  and Close_Date_Current_Quarter__c = True and StageName = 'Closed Won'
                     group by Owned_By__c
                     ORDER BY sum(Amount) ASC
                     LIMIT 10];
            for (AggregateResult ar : lstAR)
                System.debug(ar.get('owner')+'-'+ar.get('amt'));
        }
        
        
        
        else if (this.currentUser.ReportLevel__c == 'Sales Director')
        {
            lstAR = [select Owned_By__c, sum(Amount) amt
                     from Opportunity
                     where Opportunity.Region_SGI__c = :this.currentUser.RegionSGI__c and Close_Date_Current_Quarter__c = True and StageName = 'Closed Won'
                     group by Owned_By__c
                     ORDER BY sum(Amount) ASC
                     LIMIT 10];
            for (AggregateResult ar : lstAR)
                System.debug(ar.get('owner')+'-'+ar.get('amt'));
        }
        
        
        else if (this.currentUser.ReportLevel__c == 'VP of Sales')
        {
            lstAR = [select Owned_By__c owner, sum(Amount) amt
                     from Opportunity
                     where Opportunity.Owner.Country = :this.currentUser.Country and
                     Close_Date_Current_Quarter__c = True and StageName = 'Closed Won'
                     group by Owned_By__c
                     ORDER BY sum(Amount) ASC
                     LIMIT 10];
            for (AggregateResult ar : lstAR)
                System.debug(ar.get('owner')+'-'+ar.get('amt'));
        }
        
        
        else if (this.currentUser.ReportLevel__c == 'Corporate')
        {
            lstAR = [select Owned_By__c owner, sum(Amount) amt
                     from Opportunity
                     where Close_Date_Current_Quarter__c = True and StageName = 'Closed Won'
                     group by Owned_By__c
                     ORDER BY sum(Amount) ASC
                     LIMIT 10];
            for (AggregateResult ar : lstAR)
                System.debug(ar.get('owner')+'-'+ar.get('amt'));
        }
        
        List<oppClass> Top10List = new List<oppClass>();
        for (AggregateResult ar : lstAR) {
            Top10List.add(new oppClass(ar));
        }
        return;
    }
    
    //wrapper
    public class oppClass  
    {  
        String OwnedBy { get; private set; }  
        public Double Amount { get; private set; }  
        
        public oppClass(AggregateResult ar)  
        {  
            OwnedBy = String.valueOf(ar.get('owner'));  
            Amount = Double.valueOf(ar.get('amt'));  
            
        }  
    }  
}

 
Best Answer chosen by Justin Ruck
Justin RuckJustin Ruck
I figured it out.  Change:
 
List<oppClass> Top10List = new List<oppClass>();

To:
 
Top10List = new List<oppClass>();

 

All Answers

kevin lamkevin lam
You need to change the two outputText lines:

<apex:outputText value="{!ar.OwnedBy}"/>
<apex:outputText value="{!ar.Amount}"/>
Justin RuckJustin Ruck
Kevin,

I tried that, but now I get an error message:

Unknown property 'HomeGamificationController.oppClass.OwnedBy'
kevin lamkevin lam
Change line 94 to:

public String OwnedBy { get; private set; }
Justin RuckJustin Ruck
The error is gone, but the VF page is still only showing headers with no data below it.  
Justin RuckJustin Ruck
I figured it out.  Change:
 
List<oppClass> Top10List = new List<oppClass>();

To:
 
Top10List = new List<oppClass>();

 
This was selected as the best answer