You need to sign in to do that
Don't have an account?

not able to get values into the controller from the VF page
Hi all,
am new to visual force and am trying to get values from my visual force page for further processing but am getting null values in my controller .
Can any one let me know what is the problem??
Here is my code snippet.
VF page :
------------
Controler :
------------
public class paginationController {
public string queryString{get;set;}
public List<SampleObject001__c> userDetails{get;set;}
public paginationController(){
queryString='Select First_Name__c,Last_Name__c,Country__c From SampleObject001__c';
executeQuery();
}
public List<String> countries {
get {
if (countries == null) {
countries = new List<String>();
Schema.DescribeFieldResult field = SampleObject001__c.Country__c.getDescribe();
for (Schema.PicklistEntry f : field.getPicklistValues())
countries.add(f.getLabel());
}
return countries;
}
set;
}
public PageReference searchFunctionality(){
String firstName = Apexpages.currentPage().getParameters().get('firstname');
String lastName = Apexpages.currentPage().getParameters().get('lastname');
String country = Apexpages.currentPage().getParameters().get('country');
system.debug('-----firstName-------'+firstName);
system.debug('-----lastName-------'+lastName);
system.debug('-----country-------'+country);
if(firstName!=null && !firstName.equals('')){
queryString+='and First_Name__c LIKE \''+String.escapeSingleQuotes(firstName)+'%\'';
}
if(lastName!=null && !lastName.equals('')){
queryString+='and Last_Name__c LIKE \''+String.escapeSingleQuotes(lastName)+'%\'';
}
if(country!=null && !country.equals('')){
queryString += ' and Country__c includes (\''+country+'\')';
}
executeQuery();
return null;
}
public void executeQuery(){
try{
system.debug('-----QUERY-------'+queryString);
userDetails= Database.query(queryString);
}catch(Exception e){
}
}
}
please help me to resolve this issue.
There are two problems that I can see.
Your button is making an ajax call, however it is not canceling the default behavior of the commandButton which is to submit the form.
Fix this with
Also, your actionFunction needs to be configured to refresh your debug pageBlock after the ajax call is complete. Check out the reference for apex:actionFunction.
You might also consider using the apex:actionStatus to show the status of the ajax call.
Regards,
Mark
Thanks allot mark for giving me the clear information. Now i can able to get the values into my controller.
Thanks allot for your help.
regards,
Adi.
Would you mind marking my post as the solution?
Thanks,
Mark