0

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}"/>
</apex:commandButton>

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! :(

1 Answer 1

5

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
  • 1
    Ya, all I had to do was this: <apex:inputText label="Email" value="{!ProvidedEmail}"/> lol.
    – Darkenor
    Commented Oct 22, 2012 at 19:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .