Search code examples
apex-codevisualforceforce.com

Apex:Datalist showing empty results


I'm trying to show a list of rows from a custom object in a datalist.

When I try this on a regular object it seems to work, which is rather strange.

Controller

     List<Account> accounts;
     public List<Account> getAccounts() {
        if(accounts == null) accounts = [select id from Account limit 10];
        return accounts;
     }

Visualforce

     <apex:dataList value="{!accounts}" var="account" id="theList">
        <apex:outputText value="{!account.id}"/> 
     </apex:dataList>

This works just like it use to, it shows the id for all accounts. When I use a custom object I get an empty bullet list. Like:

empty list

This has the correct amount of bullets (there are 3 items).

My Controller is now this

     List<AttributeMeetingroomAssociation__c> accounts;
     public List<AttributeMeetingroomAssociation__c> getAccounts() {
        if(accounts == null) accounts = [select id from AttributeMeetingroomAssociation__c limit 10];
        return accounts;

     }

[select id from AttributeMeetingroomAssociation__c limit 10] gives the 3 correct results when I use them in the salesforce.schema

Anyone has a solution to this problem?


Solution

  • If you are in Develop site, let check your FLS (Field Level Security) on the field. Go to Setup > Develop > Sites > Site Label > Public Access Settings > Scroll to Custom Field Level Security > Object Name [View] > Edit. Check the "Visible" marks for all fields they should have access to, and save.