Interface CartEntryActionHandler

All Known Implementing Classes:
ConfigCopyCartEntryActionHandler, RemoveCartEntryActionHandler, SaveForLaterActionHandler

public interface CartEntryActionHandler
Handler interface for the execution of CartEntryAction.
  • Method Summary

    Modifier and Type
    Method
    Description
    Provides the key to the message that should be displayed when a CartEntryActionException is thrown.
    Provides the key to the message that should be displayed when an action runs with success.
    handleAction(List<Long> entryNumbers)
    This method contains the logic of the action performed by the CartEntryActionHandler implementation.
    boolean
    This method determines if the action should show or not in the cart entry tools menu.
  • Method Details

    • handleAction

      Optional<String> handleAction(List<Long> entryNumbers) throws CartEntryActionException
      This method contains the logic of the action performed by the CartEntryActionHandler implementation. Even though the method supports(CartEntryModel) prevents unsupported actions to be visible in the contextual menu, it is the responsibility of the handleAction method and the processes it calls to perform appropriate validations in case the action is called on a cart entry for which it should not.
      Parameters:
      entryNumbers - the cart entry number for which the action is executed.
      Returns:
      An empty optional to signal the controller to apply the default behaviour: redisplay the cart page with a success message. Otherwise return a custom redirect URL to navigate elsewhere upon the action completion. The expected url format is the format used as SpringMVC controller method return values.
      Throws:
      CartEntryActionException - when an error occurs.
    • getSuccessMessageKey

      String getSuccessMessageKey()
      Provides the key to the message that should be displayed when an action runs with success.
      Returns:
      the success message key.
    • getErrorMessageKey

      String getErrorMessageKey()
      Provides the key to the message that should be displayed when a CartEntryActionException is thrown.
      Returns:
      the error message key.
    • supports

      boolean supports(CartEntryModel cartEntry)
      This method determines if the action should show or not in the cart entry tools menu. An action may not be supported by every cart entry and this is the method to override to make this decision. This method is intended to refine the contents of the contextual menu of a cart item. It is the responsibility of the method and the processes it calls to perform appropriate validations in case the action is called on a cart entry for which it should not.
      Parameters:
      cartEntry - the cart entry model.
      Returns:
      true if the cart entry supports the action, false otherwise.