Class BroadleafAbstractController

java.lang.Object
org.broadleafcommerce.common.web.controller.BroadleafAbstractController
Direct Known Subclasses:
AbstractAccountController, AbstractCartController, AbstractCatalogController, AbstractCheckoutController, AbstractCustomerAddressController, AdminAbstractController, AdminLoginController, BroadleafCategoryController, BroadleafChangePasswordController, BroadleafContactUsController, BroadleafLoginController, BroadleafManageCustomerPaymentsController, BroadleafOrderConfirmationController, BroadleafPageController, BroadleafProductController, BroadleafRegisterController, BroadleafSkuController, BroadleafUpdateAccountController, CustomerPaymentGatewayAbstractController, PaymentGatewayAbstractController

public abstract class BroadleafAbstractController extends Object
An abstract controller that provides convenience methods and resource declarations for its children

Operations that are shared between all controllers belong here. To use composition rather than extension, implementors can utilize BroadleafControllerUtility.

Author:
apazzolini, bpolster
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected <T> void
    addDeepLink(org.springframework.web.servlet.ModelAndView model, DeepLinkService<T> service, T item)
     
    protected String
    getContextPath(jakarta.servlet.http.HttpServletRequest request)
    Returns the current servlet context path.
    protected boolean
    isAjaxRequest(jakarta.servlet.http.HttpServletRequest request)
    A helper method that returns whether or not the given request was invoked via an AJAX call
    protected String
    jsonResponse(jakarta.servlet.http.HttpServletResponse response, Map<?,?> responseMap)
    Typically, controller methods are set to return a String that points to the necessary template path.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BroadleafAbstractController

      public BroadleafAbstractController()
  • Method Details

    • isAjaxRequest

      protected boolean isAjaxRequest(jakarta.servlet.http.HttpServletRequest request)
      A helper method that returns whether or not the given request was invoked via an AJAX call
      Parameters:
      request -
      Returns:
      - whether or not it was an AJAX request
    • getContextPath

      protected String getContextPath(jakarta.servlet.http.HttpServletRequest request)
      Returns the current servlet context path. This will return a "/" if the application is deployed as root. If it's not deployed as root, it will return the context path BOTH a leading slash but without a trailing slash.
      Parameters:
      request -
      Returns:
      the context path
    • addDeepLink

      protected <T> void addDeepLink(org.springframework.web.servlet.ModelAndView model, DeepLinkService<T> service, T item)
    • jsonResponse

      protected String jsonResponse(jakarta.servlet.http.HttpServletResponse response, Map<?,?> responseMap) throws com.fasterxml.jackson.core.JsonGenerationException, com.fasterxml.jackson.databind.JsonMappingException, IOException
      Typically, controller methods are set to return a String that points to the necessary template path.

      However, there may be occasions where the error state for a controller action should instead return JSON instead of a fully rendered template. This convenience method will achieve that by setting the appropriate headers and serializing the given map.

      Parameters:
      response -
      responseMap -
      Throws:
      com.fasterxml.jackson.core.JsonGenerationException
      com.fasterxml.jackson.databind.JsonMappingException
      IOException