pagereference return null vs void

I feel like I’ve noticed differences in the past between a pageReference returning null vs a void method. However, I can’t recall now, does the pageReference returning null refresh the view state? Are they supposed to act identically?


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.

A PageReference is a reference to an instantiation of a page. Among other attributes, PageReferences consist of a URL and a set of query parameter names and values.
Use a PageReference object:
To view or set query string parameters and values for a page
To navigate the user to a different page as the result of an action method.

Source : Link , Question Author : Phil B , Answer Author : Daniel Blackhall

Leave a Comment