Reputation: 2917
How to redirect to the same page (I don't know the page; the redirection is done inside a menu shared by several pages) ?
I tried
return "?faces-redirect=true";
at the end of the action method, but I received an error message because it is not possible to find a navigation case for "?faces-redirect=true".
Thanks in advance for your help.
Upvotes: 10
Views: 6404
Reputation: 1109572
You need to supply a valid view ID in the outcome and not only a query string. You can obtain the current view ID by UIViewRoot#getViewId()
.
String viewId = FacesContext.getCurrentInstance().getViewRoot().getViewId();
return viewId + "?faces-redirect=true";
Upvotes: 21
Reputation: 2255
Simply return null
or an empty string from your application action.
As per JSF2.2 spec, section 7.4.1:
If the outcome returned by the application action is null or the empty string, and none of the navigation cases that map to the current view identifier have a non-null condition expression, the same view must be re-displayed.
Upvotes: -1