I have a Visualforce page, with a pageblocktable that is dependent on some date fields. When the dates change I would like to rerender the table, and then rerender the pageMessages. At the moment, they rerender at the same time, so the error message doesn't disappear if the error is corrected. I would like the messages to rerender once the getRowList() method has run.
Visualforce:
<apex:pageBlockSection title="Select Dates (Optional)" columns="2">
<apex:input value="{!startDate}" label="Start" id="date1">
<apex:actionSupport event="onchange" action="{!getSelected}" rerender="timeline,messages"/>
</apex:input>
<apex:input value="{!endDate}" label="End" id="date2">
<apex:actionSupport event="onchange" action="{!getSelected}" rerender="timeline,messages"/>
</apex:input>
</apex:pageBlockSection>
<apex:pageMessages id="messages"/>
<apex:outputPanel id="timeline">
<apex:pageBlockSection title="Timeline" rendered="{!rowList.size>0}" columns="1">
<apex:pageBlockTable value="{!rowList}" var="r" >
Apex Controller:
public List<Row> getRowList(){
if(startDate > endDate){
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Sorry, start date must be before end date.'));
}
return new List<Row>{Some instances of wrapper....}
}