+ Start a Discussion

how to pass value from vf page to controller ??

how to pass value from vf page to controller ??
refer link for reference - http://salesforce.stackexchange.com/questions/36580/passing-a-value-from-visualforce-page-to-controller

Hi Madhu, 
Just call the datatype in the visual force page. That should work.
//Apex Class
class vf_controller {
   public string variable {get; set;}
   variable = 'Apple';

VF page:
<apex:inputField value = {!variable} />

Hope that helped!

You need to define a public variable with getters and setters and use standard visualforce page input tags for that variable so that it gets binded to your visualforce page. Something like below:
---------------Apex Class---------------
public bindController {
public String bindVar {get;set;}
public bindController () {
  bindVar = 'Some Default';
public void change() {
  system.debug('Changed----' + bindVar );

---------------VF Page---------------
<apex:page controller="bindController">
    <apex:inputText value="{!bindVar}" />
    <apex:commandButton value="Change Value" action="{!change}"/>
Let us know if this helps.

How come all the answers here is the opposite. From what I understand the question is about from VF PAGE to CONTROLLER and all the answers only gave from CONTROLLER to VF PAGE.... it is easy to pass from CONTROLLER to VF PAGE but we beginner do not know how to PASS from VF PAGE back to CONTROLLER. Even when asked in the forum, we get the opposite answer. May I know whether is this even solving the question here already? 

I have the same question as this post but it never gets answered at all