+ Start a Discussion
Ankit SinghalAnkit Singhal 

How to capture input field values in VF controller

I am using extension for a Custom Object .

Sample code:

 

<apex:page standardcontroller="Applied_SMP__c" extensions="ApplyAccountSMPAgain">
<apex:PageBlock >
<apex:pageMessages />
<apex:form >
<apex:pageblocksection title="Apply SMP" >
<apex:panelGrid columns="2">
<apex:panelGroup >
<b><label>SMP</label></b>&nbsp;&nbsp;&nbsp;&nbsp;
<apex:outputText value="{!name}"/>
</apex:panelGroup></apex:panelGrid>
<br/>
<apex:inputField value="{!Applied_SMP__c.Assign_To__c}"/>
<apex:inputField value="{!Applied_SMP__c.Start_Date__c}"/>
</apex:pageblocksection>

 

 

I want to use the user entered values in above two fields in controller.

How to capture these values in controller??

Please help

Best Answer chosen by Admin (Salesforce Developers) 
APathakAPathak

Hi,

The extension controller needs to have the below code:- 

 

public class ApplyAccountSMPAgain 
{
	private Applied_SMP__c aSMP;//This variable will hold the values entered from VF page
	public ApplyAccountSMPAgain(ApexPages.StandardController stdController)
	{
		aSMP = (Applied_SMP__c)stdController.getRecord();
	}
}

 

All Answers

APathakAPathak

Hi,

The extension controller needs to have the below code:- 

 

public class ApplyAccountSMPAgain 
{
	private Applied_SMP__c aSMP;//This variable will hold the values entered from VF page
	public ApplyAccountSMPAgain(ApexPages.StandardController stdController)
	{
		aSMP = (Applied_SMP__c)stdController.getRecord();
	}
}

 

This was selected as the best answer
Ankit SinghalAnkit Singhal

I want to pass this record containing these values in a common class method.

but since this record is not yet inserted into database,how can i retrieve both these valuse in that method.

 

I dont want to pass both these values as 2 arguements ..

bpl3792bpl3792

If you're down to use jQuery JsRemoting is pretty powerful. 

Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.Your Controller.Your get method in apex}',
                          Variable your passing in method,
                          function(result, event)
                          { 
                            Do what you do.

                                    
                          },{escape: true});   

 
Also, your get method will need to have a 
@remoteaction above it and it will have to be a global method.