I want to pass list of record from VF page controller to component controller but when i access variable in component controller using object creation then i am getting null value. I am taking Example from this Controller Component Communication but in this example only controller method is called . i don't want to use attribute tag to passs data ffrom VF page to controller So is there any other way in which i can access VF Page Controller variable in Component controller.

  • 2
    Why don't you want to use an attribute? That is the standard way of doing things. – Alex Tennant Sep 20 '14 at 9:52
  • because my requirement is change so i can't use attribute – Tushar Sharma Sep 20 '14 at 9:56
  • Are you able to explain a bit more, or provide some code? At the moment I don't see why you wouldn't just pass a list in as an attribute. – Alex Tennant Sep 20 '14 at 11:03
  • @AlexTennant because it is specific requirment that we cannot use apex:attribute tag also in the given link we can access component method from page controller so i think vice-versa is also possible – Tushar Sharma Sep 20 '14 at 11:15
  • That example is using an attribute. It passes the entire page controller into the component controller. You should be able to access all of the page controller's public variables through this attribute reference. I've used this technique often. I have a feeling you're asking the wrong question, because that code is perfectly sound. – sfdcfox Sep 20 '14 at 11:37

If you follow the comments to your question you should be able to pass references from page controller to component controller and vice versa. But then you end up in a scenario where both controllers are coupled so closely together, that you may also think about using only a single controller for both.

| improve this answer | |
  • hi @Uwe Heim i am not able toass references from page controller can you help me in this – Tushar Sharma Sep 22 '14 at 8:31

As this is the old post. So now we have some workarounds.

Like using Javascript call components actionfunction and then pass the parameters. And using apex:param tag pass these values to component controller.

Second is use apex:inputputhidden and set the value and give it name and then component controller get this value using apexpages.currentpages().getparameter().get('name');

Third not so good option is use cookies to temporarily store data and then access in component controller.

and the last one (and worst of all of them) create a junk object and store data in this object and query this object's records in component controller and after calculation delete this records.

So these all available options. I suggest you to go with 1 or 2.

| improve this answer | |
  • @Arjit check my updated answer. – Tushar Sharma Jul 6 '16 at 13:15

If you pass static value you will see that problem is with dynamic values. so what you can do

public class myController{
    public integer loadOnce{get;set;}
    public string someval {get;set;}
    public myController(){
       loadOnce = 1;
       // set someval here or 

    public void dummyLoad(){
       // set someval here or 

<apex:page controller="myController"> 

<action:function name="dummyLoad" action="{!dummyLoad}" reRender="componentPanel" >
<apex:outputpanel id="componentPanel">
 <c:yourComponent attr= "{!someval}" />
 var loadcheck = "{!loadOnce}";
if(loadcheck == 1){

   <apex:attribute name="attr" type="String" description="TODO: Describe me"/>
   Viewing {!attr}

Hope this help we need to do a dummy load of the page to get the dynamic load as per the documentation component constructor called later hence value is null. I did the same few time back worked for me. There might be some syntax issue but I hope you got the logic.

| improve this answer | |

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.