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.


<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 value="{!endDate}" label="End" id="date2">
        <apex:actionSupport event="onchange" action="{!getSelected}" rerender="timeline,messages"/>
<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....}
  • Isn't the problem that you're adding an ApexPages.Message to the page, but never removing it? When you re-render a section of the page, the pagemessages stays the same. The previous error will always be there.
    – Nick C
    Commented Dec 21, 2015 at 11:35
  • @NickCook If I change the date again after correcting it, this rerenders both elements and therefore removes the pageMessages.
    – fred
    Commented Dec 21, 2015 at 11:38
  • The pageMessage is removed as soon as the pageBlockTable finishes rerendering, however, the pageMessages need to be rerendered after this happens.
    – fred
    Commented Dec 21, 2015 at 11:41

1 Answer 1


You could utilize the oncomplete attribute to ensure the order of the reRendering.


 // here you are reRendering two elements
<apex:actionSupport event="onchange" action="{!getSelected}" rerender="timeline,messages"/>

Instead, you could split them up so you know one fires before the other

<apex:actionSupport event="onchange" action="{!getSelected}" rerender="timeline" oncomplete="reRenderMessages();"/>

<apex:actionFunction name='reRenderMessages' reRender='messages'/>

I don't believe I've used this approach before, but, based on my understanding, this should meet your requirements.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .