You need to sign in to do that
Don't have an account?

How to refer VF component's controller variable in VF page which uses that component
Hi Devs ,
I have two vf page which has similar form and fields , so thinking to design a VF component and use this vf comp in both the VF pages .
But I want to refer the apex variable of custom controller of Vf component in VF page which uses it .
Can you please tell me how to do that ?
Regards,
Sanju
I have two vf page which has similar form and fields , so thinking to design a VF component and use this vf comp in both the VF pages .
But I want to refer the apex variable of custom controller of Vf component in VF page which uses it .
Can you please tell me how to do that ?
Regards,
Sanju
Please refer this https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_comp_cust_elements_controllers.htm?search_text=component
Thanks
Gulshan Raj
HI Gulshan ,
I guess you didnt get my question , What i am asking is how to refer the component's controller variable in VF page which contains that VF component . To make things more clear , Let me put an example .
/* Component name :simpleComponent */
<apex:component controller="myComponentController">
<apex:attribute name="componentValue" description="Attribute on the component."
type="String" required="required" assignTo="{!controllerValue}"/>
componentValue is "{!componentValue}"
</apex:component>
/*Component controller*/
public class myComponentController {
public String controllerValue{get;set;}
}
/* VF page that resides component */
<apex:page>
<c:simpleComponent componentValue="abc"/>
how to refer controllerValue variable here
</apex:page>
Hope you got my point.
Ideally there is no direct method through which we can interact from VF component to VF page. But there are some wayout to communicate from VF component to parent component or page.
Please follow this link https://www.sundoginteractive.com/blog/communicate-from-a-component-to-the-page-visualforce
I trust this will help you.
If this helps you, mark this question as solved and choose best answer so it will help other in future to choose best solution.
Thanks
Gulshan Raj