0

My visualforce component has the following attribute:

<apex:attribute type="SObject[][]" name="var" 
    description="Variable to store results in." 
    assignTo="{!searchResults}" required="true"/>

My components controller has the following variable:

public List<List<SObject>> searchResults {get; set;}

My page's controller has the following variable:

public List<List<SObject>> searchResults {get; set;}

My page references my component as such:

<c:EmailRecipientSearch var="{!searchResults}"/>

I am getting the following error when deploying:

force-app\main\default\pages\SendEmailForm.page Wrong type for attribute . Expected SObject[][], found VisualforceArrayList

The question:

How do I pass a List<List<SObject>> to a component via an attribute.

I know I could create a wrapper class and pass that instead but I'd like to avoid that.

The use case:

I need to pass data from my component back to my page. This was something I've done in the past but have forgotten how to make it work. I read through this question. I vaguely remembered being able to make it work without passing the entire controller and I wanted to test if my memory was correct.

I understand I can test this without needing to past a List<List<SObject>> but I do have a few other use cases where I would need to pass a nested list as an attribute so I figured I'd ask if anyone knew.

2

Sad to say, the VF Custom Components documentation is explicit

One-dimensional lists, specified using array-notation, such as String[], or Contact[].

You'll need to pass a custom type instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.