I have a VF page using a standard controller, a component, and a custom controller for the component. I am trying to pass a list of sObjects from the standard controller to the component's custom controller. Currently, I have it set up as follows:

In VF page:

 <c:ProjectSummaryComponent project="{!Project__c}" summaries="{!Project__c.Project_Summaries__r}" />

In VF component:

   <apex:component controller="ProjectSummaryController">
       <apex:attribute name="project" type="Project__c" required="true" description="The Project__c record" />
       <apex:attribute name="summaries" type="Project_Summary__c[]" assignTo="{!projectSummaries}" required="true" description="The list of Project Summaries." />

In controller:

public with sharing class ProjectSummaryController {
    public Project_Summary__c[] projectSummaries {get; set;}

I get no build errors from this code, but when viewing the page, I get this Visualforce error message:

Cannot convert the value of '{!projectSummaries}' to the expected type. 

I'm not sure what is wrong here, since the type is specified to be Project_Summary__c[] in both the component and the controller. From the component, I can actually display the list of Project_Summary__c records that were passed from the main page.

Any help would be appreciated. Thanks.

  • 1
    Square brackets are only supported in some contexts. Try using List<Project_Summary__c> instead.
    – sfdcfox
    Nov 26, 2014 at 0:37
  • I've actually tried using List<Project_Summary__c>. If I substitute Project_Summary__c[] with List<Project_Summary__c> in the VF component, I get a build error stating List<Project_Summary__c> is an unsupported type. Substituting the [] with List in the controller doesn't seem to make a difference.
    – John L
    Nov 26, 2014 at 16:57

1 Answer 1


I confirmed this behavior in my own test and was able to work around it as follows:

VF component:

<c:ProjectSummaryComponent project="{!Project__c}" summaries="{!projectSummaries}" />


VF controller:

private Project__c  getProjWSummaries (){
                            return [select id, name, 
                                       (select id, name from Project_Summaries__r) 
                                     from Project__c where id = :this.project__c.id][0];}
public List<Project_Summary__c> projectSummaries {
   get {return getProjWSummaries().project_summaries__r;} private set; }  

VF component: no change

The problem has something to do with the relationship Project_Summaries__r if provided directly as you did in the OP when assigned to the component's controller. What exactly I do not know. As you can see from the code above, simply fetching the relationship in a property of List type works fine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .