Class SetLocaleCommand<C extends WebContext>

java.lang.Object
org.apache.commons.chain.web.jakarta.SetLocaleCommand<C>
Type Parameters:
C - Type of the context associated with this command
All Implemented Interfaces:
Command<C>

public abstract class SetLocaleCommand<C extends WebContext> extends Object implements Command<C>
Base Command implementation for setting the response locale for this response to the Locale stored under the context attribute key returned by the localeKey property.
Since:
Chain 1.3
Author:
Stefan Graff
  • Constructor Details

    • SetLocaleCommand

      public SetLocaleCommand(BiConsumer<C,Locale> localeBiConsumer)
      Construct a new instance to set the locale into the context.
      Parameters:
      localeBiConsumer - BiConsumer to set the Locale into the context
  • Method Details

    • getLocaleKey

      public String getLocaleKey()
      Return the context attribute key under which we will retrieve the response Locale.
      Returns:
      The context attribute key of the request Locale.
    • setLocaleKey

      public void setLocaleKey(String localeKey)
      Set the context attribute key under which we will retrieve the response Locale.
      Parameters:
      localeKey - The new context attribute key
    • execute

      public boolean execute(C context) throws Exception
      Retrieve the Locale stored under the specified context attribute key, and establish it on this response.
      Specified by:
      execute in interface Command<C extends WebContext>
      Parameters:
      context - The Context we are operating on
      Returns:
      false so that processing will continue
      Throws:
      Exception - If an error occurs during execution.