You can do it by maintaining the values atPlease refer this code for your class side
Create new varaible;
private List<SelectOption> options;
initialize it in constructor at 1st line;
options = new List<SelectOption>()
then.
from this methodI have created a new String variable getName
remove this line
List<SelectOption> options = new List<SelectOption>();strGeographix
and you are done with your solution.
earlier what was happening, when ever you was changing thewhich will store geograpic values of Country,and put in your optionserrorMap
List was re-initializingon every timecall.
public class RfpControllerExtension2 {
public string model{get;set;}
public List<String> SelectedDept{get;set;}
public List<Geography__c> results{get;set;}
public List<SelectOption> AllDept{get;set;}
public List<SelectOption> AllName{get;set;}
public List<String> SelectedName{get;set;}
public String discountScheduleID { get; set; }
private String strGeographix = '';
public RfpControllerExtension2 (){
AllDept= new List<SelectOption>();
AllDept= getDept();
AllName= new List<SelectOption>();
AllName= getName();
}
public void FindAllName()
{
system.debug('@@@@@@ Entered');
AllName= new List<SelectOption>();
AllName= getName();
}
public List<SelectOption> getDept()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('Select','--Select--'));
Schema.DescribeFieldResult departfield = Geography__c.Country__c.getDescribe();
List<Schema.PicklistEntry> picklist = departfield.getPicklistValues();
for( Schema.PicklistEntry f : picklist){
options.add(new SelectOption(f.getLabel(), f.getValue()));
}
return options;
}
public List<SelectOption> getName()
{
List<SelectOption> options = new List<SelectOption>();
Set<String> sProj = new Set<String>();
if(discountScheduleID != null )
{
for(Geography__c Proj :[select Id, Canonical_Name__c, Type__c from Geography__c where status__c = 'active' AND Country__c =: discountScheduleID order by Canonical_Name__c] )
{
options.add(new SelectOption(Proj.ID,Proj.Canonical_Name__c));
strGeographix += Proj.Canonical_Name__c + ', ';
}
}
errorMap.put('selectedGeographies',Proj.Canonical_Name__c);
return options;
}
public Map<String, String> errorMap {
get {
if (errorMap == null || errorMap.size() == 0) {
errorMap = new Map<String, String> {
'selectedGeographies' => '',
'flightDates' => '',
'agency' => '',
'agencyContact' => ''
};
}
return errorMap;
}
private set;
}
}