I'd like to retrieve the value a user has placed in an apex:inputtext box and pass it to my controller. As simplified as I can get it, this is what I'd like to do:

User inputs email address into box.
Controller takes input, looks up contact info.
Display contact details in visualforce.
Great success!

What I don't understand is how I can grab the value from the input text and pass it as a parameter, kind of like this:

<apex:commandButton value="Submit" action="{!setEmail}" reRender="ContactsFoundBlock">
    <apex:param name="emailParam" value="notSureWhatToPutHere" assignTo="{!ProvidedEmail}"/>

setEmail - assigns a public property "ProvidedEmail" to a private variable that is used for a lookup.

I think I'm just...doing something wrong. Apologies if the code is sloppy and confusing, but I'm a little confused myself! :(


You can bind apex:inputText to a variable on your controller. You can bind apex:inputField to an sObject field in your controller When you hit the commandButton the viewstate will be transmitted and the variable assignment will happen, you don't need to explicitly pass in the value as a parameter. Just access the variable in your controller as normal.

  • 1
    Ya, all I had to do was this: <apex:inputText label="Email" value="{!ProvidedEmail}"/> lol.
    – Darkenor
    Oct 22 '12 at 19:15

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.