Class BroadleafRedirectController

java.lang.Object
org.broadleafcommerce.common.web.controller.BroadleafRedirectController

public class BroadleafRedirectController extends Object
This controller works in conjunction with the broadleaf-ajax style redirect.

The logic is quite complex but solves a problem related to redirects and an Ajax form.

It is intended to solve a problem with using an Ajax style login modal along with Spring Security.

Spring Security wants to redirect after a successful login. Unfortunately, we can reliably redirect from Spring Security to a page within the BLC system when the login modal is presented in Ajax.

To solve this problem, Spring Security can be configured to use the BroadleafWindowLocationRedirectStrategy. That strategy will add an attribute to session for the page you want to redirect to if the request is coming in from an Ajax call. It will then cause a redirect that should be picked up by this controller. This controller will then render a page with the blc-redirect-div. The client-side javaScript (BLC.js) will intercept this code and force the browser to load the new page (e.g. via window.location)

Author:
bpolster
See Also:
  • BroadleafRedirectStrategy
  • Constructor Details

    • BroadleafRedirectController

      public BroadleafRedirectController()
  • Method Details

    • redirect

      public String redirect(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model)