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
Raj01Raj01 

How to pass the value from Component controller to Visualforce page

Hi,

I have a value in my Component controller and i would like to pass the value to my page controler. I am not using the same controller.

Any help is really appreciated. 
karthikeyan perumalkarthikeyan perumal
Hello, 

If you want access variable value in page kinldy use blow sample code: 

----------- vf page----------------
 
<apex:page controller="accessmergefieldinjavascript" >

<script>
var stringvalue='{!s}';
var integervalue='{!nn}';
alert(' stringvalue '+stringvalue+' integervalue '+integervalue);
</script>

</apex:page>

------------ Apex controller -----------------
 
public class accessmergefieldinjavascript
{

public string s{get;set;}
public integer nn{get;set;}
public accessmergefieldinjavascript ()
{
s='hello';
nn=10;
}

}


OR 

if you want pass value from page to controlle kinldy use below sample code: 

sample page: 
<script>
    window.setTimeout(function() { setParams("param1Value", "param2Value"); }, 1);
</script>

<apex:actionRegion>
    <apex:actionFunction action="{!setParams}" name="setParams" rerender="dummy">
        <apex:param name="param1" assignTo="{!param1}" value="" />
        <apex:param name="param2" assignTo="{!param2}" value="" />
    </apex:actionFunction>
    <apex:outputPanel id="dummy"/>
</apex:actionRegion>
sample class: 
 
public class ParameterPageController
{
    public String param1 { get; set; }
    public String param2 { get; set; }

    public PageReference setParams()
    {
        return null;
    }
}

Hope it will clear. 
if its clear makr it solved

Thanks
karthik