I have several visualforce components inside a Visualforce page. Instead of doing my SOQL queries inside each component (through an apex controller), I'd like to have a single soql query inside the VF page controller and pass resulting data (ieally as an array) to my VF components.

Current Page Code looks like: <c:component1 /> <c:component2 />

Is passing values (as an array) into these components through the vf page housing them possible to do?

1 Answer 1


Yes it is. You can pass in specific values:

    <apex:attribute name="sobs" type="MyCustomObject__c[]" description=""/>

or indeed a reference to the page controller

    <apex:attribute name="c" type="PageController" description=""/>

and then use expressions like { !c.property } to reference values from the controller.

Just a question of whether you want the component to be fully self-contained or not.

  • Thanks Keith! This is great to know.
    – ust
    Nov 22, 2020 at 13:07

You must log in to answer this question.

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