function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dsh210@lehigh.edudsh210@lehigh.edu 

Parameters for Custom Component Controller

Hey All,

 

I am trying to create a custom component that will be repeated many times on a page. However, I was looking to pass some parameters into the controller of this component. Is there any way I can have visualforce do this rather than just calling the standard controller? The issue I am trying to solve is rendering several pageblocks for different parts of a set of data. I want to be able to pass the list of data pieces into the constructor so I can use a pageblocktable to render it in the component.

 

Thanks for any suggestions,

DH

bmabma

You can create use the "assignTo" attribute in <apex:attribute> to pass parameters from your page to the component's controller.

 

Component Controller:

 

public class CmpCtr {
  public String value {get; set;}
}

 

 

Component Markup:

 

<apex:component controller="CmpCtr">
  <apex:attribute type="String" name="value" assignTo="{!value}" description="Value to pass into the controller"/>
 ...
</apex:component>

 

Page Markup:

 

<apex:page controller="PageCtr">
 <c:cmp value="{!PageCtrValue}"/>
 ...
</apex:page>

 

 

Hope this helps

bma