Find your content:

Search form

You are here

How can I get the value a user input into an apex:inputtext box?

 
Share

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


Attribution to: Darkenor

Possible Suggestion/Solution #1

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.


Attribution to: techtrekker
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/3580

My Block Status

My Block Content