I'm having a VF page which shows a table, together with 2 dropdowns and a checkbox which function as filters. Whenever a picklist value or the checkbox changes, the table should get rerendered having the data filtered according to the selection specified.
The used actionSupport
properly calls the method and the values are sent correctly according to the request info in the network tab in the browser.
The variables in the controller though are not set properly, and usually take the values of a previous selection.
I suspect a race condition somewhere but I have no clue how to solve it or how to approach this.
Visualforce:
<apex:selectList value="{!selectedPeriod}" label="Period" size="1" required="true">
<apex:selectOptions value="{!filterPeriods}"/>
<apex:actionSupport event="onchange" action="{!doFilter}" reRender="outpanel"/>
</apex:selectList>
<apex:selectList value="{!selectedStatus}" label="Status" size="1" required="true" multiSelect="false">
<apex:selectOptions value="{!filterStatuses}"></apex:selectOptions>
<apex:actionSupport event="onchange" action="{!doFilter}" reRender="outpanel"/>
</apex:selectList>
<apex:inputCheckbox value="{!showChildless}" label="Show records without childs">
<apex:actionSupport event="onchange" action="{!doFilter}" reRender="outpanel"/>
</apex:inputCheckbox>
<apex:outputPanel id="outpanel">
<!-- TABLE WITH DATA FROM {!recordMap} -->
</apex:outputPanel>
Controller:
public String selectedPeriod {get;set;}
public String selectedStatus {get;set;}
public Boolean showChildless {get;set;}
public Map<String, List<MyRecord__c>> recordMap {get;set;}
public MyController() {
selectedPeriod = '';
selectedStatus = '';
showChildless = true;
}
public void doFilter() {
System.debug(selectedPeriod); // outputs old value
System.debug(selectedStatus); // outputs old value
System.debug(showChildless); // outputs always true
// populate recordMap
}
public List<SelectOption> getFilterPeriods() {
// return period SelectOpion[]
}
public List<SelectOption> getFilterStatusOptions() {
// return status SelectOption[]
}
Any ideas? Thanks!