pass value from visualforce page to controller

The first thing a apex programmer wants to know is: how do we communicate between visual force page and controller. How to pass parameters from a visualforce page to a controller class ?

Lets develop a example that will capture a input in the visualforce page and pass the input value to the controller.

                      Visualforce page:



          Controller




In this example,
your {get;set} variable is binded to your input text box which makes it possible to get the value in the controller and also vice versa.

Thus when you press button the input value is passed on to controller.
<apex:inputText value="{!myinput}"/> your input text box is bind to the varaible myinput string which is defined as get;set;

When the method is called from the submit button this value from myinput string is assigned to the myoutput string. This is proved when your input value is displayed in output section.

Note: Whenever we have any component wherein we want to input a value it is necessary that that component is enclosed between <apex:form>

19 comments:

  1. Very usefull post for salesforce and Apex beginner...Plz keep posting and help beginners like me...!!!

    ReplyDelete
  2. Great Blog....Thanks..

    ReplyDelete
  3. thank you ....great blog ...keep on ....:)

    ReplyDelete
  4. Great job Yoganand....thank you......keep up the good work.....:)

    ReplyDelete
  5. Thanks bravo !! You are doing wonderful job .. keep posting we wanna learn as much as you can teach us !! :)

    ReplyDelete
  6. good post dear anyone can easily learn through this

    ReplyDelete
  7. Great Job Thanks !!!

    ReplyDelete
  8. please change i to caps lock or small in the variable myInput .I had seen one error

    ReplyDelete
  9. Great Help! Please keep doing it. Thanks!!!

    ReplyDelete
  10. very good explanation. it's very helpful for beginers...keep it up.share more information.

    ReplyDelete
  11. Bro awesome explained thanx..

    ReplyDelete
  12. This is awesome site and helps salesforce biggers a lot!!!! Thank you so much!!

    ReplyDelete
  13. Thank you very much

    ReplyDelete
  14. This site is very goog and helpfull to all salesforce learners, Thank you so much

    ReplyDelete
  15. thank you v much.. to give things in such easy way..

    ReplyDelete
  16. tag is also the one used to transfer values from VF page to controller. should have mentioned that here as well.

    ReplyDelete
  17. why we rerender outputid in inputtext button? please help me i am new to salesforce

    ReplyDelete