Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I redirect to a new page in a FreeMarker template?

I'm using a custom Magnolia forms module (built internally at my company). When the user successfully submits the form, I want to redirect the user to a success page.

This could be done in the module itself. However, if the user does not successfully submit the form (e.g. missing required fields), I need to display error messaging.

For this reason, I need to use FreeMarker to implement the redirect.

How do I redirect to a new page in a FreeMarker template?

like image 458
Ryan Payne Avatar asked Jul 19 '19 19:07

Ryan Payne


1 Answers

Use the send redirect method. For example:

${ctx.response.sendRedirect("http://google.com")!}

References

  • Rendering context objects
  • WebContext.getResponse
  • HttpServletResponse.sendRedirect
like image 93
Ryan Payne Avatar answered Sep 29 '22 02:09

Ryan Payne