You need to sign in to do that
Don't have an account?
Jimmydnet
Simple Question about Custom List Controlers
I am just starting out on the development side of SalesForce and wanted to know if I could get some input from the experts on if I am going down the right path with my current project. Thank you for any help you can provide.
I have two simple custom objects
Locations
Children
I am trying to build a VisualForce page that will query and display all the locations and in that query also query the children table to count how many children are associated to that location. The report would be
Location Name, Number of Active Children.
I have the SoQL to generate a list of locations__C. I have the SoQL to get the count from chidren__c based on the requirements. I was able to make a nice SF page but I am having a hard time making a page that combines the data to show the location name and the number of children per that location name.
Would a custom list controller be what I want to do?
I was looking at this example
https://goo.gl/zyrBHE
but I am having a hard time getting it going. I am able to get the code going as it stands but when I try to change the SoQL to something simple it tells me that I can convert that data to a list.
Here is the sample APEX code
public class opportunityList2Con {
// ApexPages.StandardSetController must be instantiated
// for standard list controllers
public ApexPages.StandardSetController setCon {
get {
if(setCon == null) {
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
[SELECT Name FROM Food_Locations__c]));
}
return setCon;
}
set;
}
// Initialize setCon and return a list of records
public List<Object> getOpportunities() {
return (List<Object>) setCon.getRecords();
}
}
VF Code
<apex:page controller="opportunityList2Con">
<apex:pageBlock >
<apex:pageBlockTable value="{!opportunities}" var="o">
<apex:column value="{!o.Name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
I have two simple custom objects
Locations
Children
I am trying to build a VisualForce page that will query and display all the locations and in that query also query the children table to count how many children are associated to that location. The report would be
Location Name, Number of Active Children.
I have the SoQL to generate a list of locations__C. I have the SoQL to get the count from chidren__c based on the requirements. I was able to make a nice SF page but I am having a hard time making a page that combines the data to show the location name and the number of children per that location name.
Would a custom list controller be what I want to do?
I was looking at this example
https://goo.gl/zyrBHE
but I am having a hard time getting it going. I am able to get the code going as it stands but when I try to change the SoQL to something simple it tells me that I can convert that data to a list.
Here is the sample APEX code
public class opportunityList2Con {
// ApexPages.StandardSetController must be instantiated
// for standard list controllers
public ApexPages.StandardSetController setCon {
get {
if(setCon == null) {
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
[SELECT Name FROM Food_Locations__c]));
}
return setCon;
}
set;
}
// Initialize setCon and return a list of records
public List<Object> getOpportunities() {
return (List<Object>) setCon.getRecords();
}
}
VF Code
<apex:page controller="opportunityList2Con">
<apex:pageBlock >
<apex:pageBlockTable value="{!opportunities}" var="o">
<apex:column value="{!o.Name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>