Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to redirect to the same page after a POST request

Tags:

jsf-2

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.

like image 748
user1643352 Avatar asked Oct 01 '13 14:10

user1643352


1 Answers

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";
like image 174
BalusC Avatar answered Sep 19 '22 21:09

BalusC