I am trying to display the list returned form this method onto a visualforce page but not having any luck. Any help would be appreciated
public List<Account> accresults {get;set;}
public List<Account> getAccounts(Integer NumberOfRecords){
List<Account> accountList = [SELECT Id FROM Account where Status__c = 'Open' Limit 5];
Map<Id, Account> selectedAccountsMap = new map<Id, Account>();
Account account;
List<Account>accResults = new List<Account>();
Integer rand;
Integer count = accountList.size();
//Integer numberOfRecordsToSelect = 25;
Integer i = 1;
while (i <= NumberOfRecords){
rand = randomWithLimit(count);
System.debug('Random Number: ' + rand);
account = accountList[rand];
if(selectedAccountsMap.get(account.Id) == null)
{
selectedAccountsMap.put(account.Id, account);
i++;
}
}
accresults.addAll(selectedAccountsMap.values());
system.debug(accresults);
return accresults;
}
public static Integer randomWithLimit(Integer upperLimit){
Integer rand = Math.round(Math.random()*1000);
return Math.mod(rand, upperLimit);
}