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
DortegalizardoDortegalizardo 

Help displaying VisualForceArraylist

This si my current Controller:

 

public class CalendarEventController{

public List <Account> getMyAccounts()
{
return [SELECT Id, Name, Region__c FROM Account ORDER BY LastModifiedDate DESC LIMIT 10];
}

public List<ActivityHistory> Actividades {get; set;}
public List<List<ActivityHistory>> lista {get;set;}
public List<List<ActivityHistory>> getOpen()
{

lista = new List<List<ActivityHistory>>();
SObject[] accounts = [SELECT Name,
(Select Subject, WhoId,WhatId, ActivityDate, Status, Priority, OwnerId FROM ActivityHistories) From Account];
/*for(Integer i = 0; i< accounts.size(); i++ )
{
if(accounts[i] != null)
{
Actividades.add(((List<ActivityHistory>)accounts.get(0).getSObjects('ActivityHistories')));
}
}*/
Actividades = (List<ActivityHistory>)accounts.get(1).getSObjects('ActivityHistories');


for(SObject o : accounts){
if(o.getSObjects('ActivityHistories') != null){
List<ActivityHistory> element = (List<ActivityHistory>) o.getSObjects('ActivityHistories');
if(element != null){
lista.add(element);
}
}

}

return lista;
}

}

 

As you may see im trying to get all the events from every account we have.

 

This is the apex code that im trying to use in order to display it on my visualforce page:

 

<apex:pageBlock>
<apex:pageBlockTable value="{!Open}" var="lista">
<apex:column value="{!lista.Subject}" headerValue="Subject"/>
</apex:pageBlockTable>
</apex:pageBlock>

 

I keep getting the same error: Error: Unknown property 'VisualforceArrayList.Subject'

Best Answer chosen by Admin (Salesforce Developers) 
kriskkrisk

Try this

 

<apex:page controller="CalendarEventController">
<apex:repeat value="{!open}" var="lista">
<apex:repeat value="{!lista}" var="item">
<apex:outputText value="{!item.Subject}" />
</apex:repeat>
</apex:repeat>
</apex:page>

 

 

All Answers

kriskkrisk

Try this

 

<apex:page controller="CalendarEventController">
<apex:repeat value="{!open}" var="lista">
<apex:repeat value="{!lista}" var="item">
<apex:outputText value="{!item.Subject}" />
</apex:repeat>
</apex:repeat>
</apex:page>

 

 

This was selected as the best answer
DortegalizardoDortegalizardo

Thanks for the help can you explain a little bit what you did. So that I can have a better picture on what to do when I have an ArrayList. Again thanks for the help.

 

Doug.

kriskkrisk

you were not looping and extracting records correctly. I just navigated the levels using right syntax.