+ Start a Discussion

Having issues with Apex:Repeat on lists

Not sure why this isn't working, but is it not enough to have get;set; on a list of objects as a getter to use them in a repeat function with a visualforce page?
public List<Custom_Quote_Item__c> quoteItemList {get;set;}

then in the visualforce page:
<apex:repeat value="{!quoteItemList}" var="qi">

I know the list has about 10 items in it but nothing is executing inside the repeat.

I also tried creating a getter function:
public List<Custom_Quote_Item__c> getQuoteItems() {
        return quoteItemList;
but that isn't working either.  I am confused why this isn't working because i am using repeat on a number of lists in my class which all seem to work find but this one isn't.  If anyone has any input I would greatly appreciate it!


If you use 
  public List<Custom_Quote_Item__c> quoteItemList {get;set;}
then you have to populate quoteItemList in the constructor of the controller.  Are you doing that?

Normally it's a best practice to use full getter pattern without a constructor like

public List<Custom_Quote_Item__c> quoteItemList {
       if(quoteItemList == null){
           // populate the first time
           quoteItemList = [select id, name from Custom_Quote_Item__c];
       return quoteItemList;

Also on the VF page you can put this in there as a debug to see the size of the list. I've never seen a repeat fail before.

size: {!quoteItemList.size}

Thanks for the info, while going through and implementing the getter suggestion you had i saw that the list was decalred again inside of the class making it a local list of the same name as the public list, and thus having an empty list when pulling from the visual force page.  once I took that out it worked as intended.  thanks for the input, simple mistake.