Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pattern for redirecting to previous page after an action

In my Play app, I have several actions (e.g. "Delete" an entity) that can be triggered from different pages. After the action is triggered, I'd like to redirect the user back to the page they were on before I performed the action. Is there a good pattern to use for this in Play?

like image 854
Bob Smith Avatar asked Jul 01 '13 14:07

Bob Smith


1 Answers

you can easily use @request.getHeader("referer") in your Templates, for example if you have a cancel button that should redirect you to the previous page, use this :

<a  href="@request.getHeader("referer")">Cancel</a>

in this way, you don't need to pass any extra information to your templates. (tested with play 2.3.4)

like image 68
behzad Avatar answered Oct 26 '22 10:10

behzad