From what I understand, when a JSF action returns "" (empty String) the user stays on the current page but the view is refreshed. However, when the action returns null the user still stays on the current page but the old view is reused. My question is:
- Is the above statement correct (accurate)?
- If yes, then what are the implications of this? Specifically, what effect does using one versus the other have on data on the page (values in JSF UI components, or data stored in a request-scope bean in a DataTable, for example)?
- In what situations should one be used over the other?
Yes. Instead of returning
nullyou can also just returnvoid.Nothing on request scoped beans. It has only effect on JSF2 view scoped beans. On returning
nullorvoid, the view scoped bean instance will be retained in the next request, else it will be recreated.If you want to retain the JSF2 view scoped bean in the subsequent request.
See also: