How to retrieve form values in traditional way on VF without binding

Thursday, September 24, 2009 by Aslam - The Alexendra
For exmaple you have a form with below fields:-

<input type="text" name="firstname"/>
<input type="text" name="lastname"/>
<apex:commandbutton value="SubmitMe" action="{!saveform}"/>

Your apex class's saveform method:-

public PageReference saveform(){
string firstName = ApexPages.currentPage().getParameters().get('firstname');

string lastName = ApexPages.currentPage().getParameters().get('lastname');

//So simple
//Do your stuff

return null

Posted in | 6 Comments »


Eric said...

That's awesome! I had no idea that worked.

Naresh said...

Thx for it:) I want to set current page's query string variable .. is there any set method like get method.. for controller's action ?

Aslam - The Alexendra said...

@Naresh: Yes, you can use...

Reena said...

You told me earlier too about this nice trick , It really helps.


Narasimha said...

This is very easy trick for retrieving the form elements. Very Useful Post!
Thanks bayya!

Haribabu@Salesforce Developer said...

wow great aslam.....thinking in new way.....

Post a Comment