I have a Visualforce page that is essentially a form with 8 steps. It uses a custom controller. I have recently moved each step into it's own component (8 in total). Now what I am wondering is, can I use the visualforce page controller without having to call the controller again within each one of my components. When I call the controller in each component I receive the error: 'System.LimitException: Too many SOQL queries: 101'. when I omit the controller all together I also receive an error. The SOQL error was not present before I moved each step into it's own component.

  • You could send the data from the visualforce page to the child components using attributes. – Martin Lezer Jan 10 at 15:48

I typically do this with the page controller directly:

<apex:page controller="XYZ">
  <c:comp1 controller="{!self}" />
  <c:comp2 controller="{!self}" />

public class XYZ {
  public XYZ getSelf() {
    return this;

<apex:component controller="ABC">
  <apex:attribute assignTo="{!pageController}" name="controller" type="XYZ" required="true" />

public class ABC {
  public XYZ pageController { get; set; }

This design can allow you to share data between all the components, typical if you're building a multi-page wizard, for example.

  • 1
    @MAS89 I typed this from memory, might a typo somewhere. Check the docs for more info. I'll see if I can find a working version in my code base. – sfdcfox Jan 10 at 17:18

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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