Tell me more ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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

share|improve this question

1 Answer

up vote 5 down vote accepted

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.

share|improve this answer
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.