Analysis
Conclusion
You do not need to return a PageReference
for rerender
to understand when the action
has completed. So if you have a method that will never cause a redirect, you can make it void
after all. Still looking for documentation one way or the other. At the bottom I have included my code used to support this conclusion. All four buttons in the example act the same.
Documentation
@Mohith Shrivastava answered a similar (but not exact) question in the thread pagereference return null vs void.
Returning Null will not refresh the view state. Unless we explicitly say that setredirect(true) the view state will be maintained. An action method with no return type (void) will not reset the view state.
The supporting link is, unsurprisingly, broken. And whether or not the view state gets refreshed does not actually answer the question of whether or not a rerender
will take place.
In the comments, @sfdcfox added:
You should return void if there is no possibility of a redirect. This makes it clear to other developers that may later view the source code that there will be no redirect from this action function without examining the entire function. This is useful when the function spans hundreds of lines and includes complex control structures. In the application I am working on finishing up, the prior developer always returned a null page reference instead of using void, and it significantly slowed down my progress.
Again, it doesn't really address the rerender
issue, but it might be the closest we get to official documentation.
Evidence
Controller
public class Example
{
public Integer calls
{
get
{
calls = (calls == null) ? 1 : ++calls;
return calls;
}
private set;
}
public PageReference doSomething() { return null; }
public void doNothing() { }
}
Page
<apex:page controller="Example">
<apex:outputPanel id="example">
<apex:outputText value="{!calls}" />
</apex:outputPanel>
<apex:form>
<apex:commandButton value="Increment" action="{!doSomething}" rerender="example" />
<apex:commandButton value="Increment" action="{!doNothing}" rerender="example" />
<apex:commandButton value="Increment" action="{!doSomething}" />
<apex:commandButton value="Increment" action="{!doNothing}" />
</apex:form>
</apex:page>