Action Filters

Filters implement the de.odysseus.calyxo.control.Filter interface. As with action commands, the controller instantiates one instance per filter configuration. After instantiation, the controller gives a filter the opportunity to do some initialization by calling its

public void init(
  FilterConfig config,
  ModuleContext context) throws Exception;

method. The de.odysseus.calyxo.control.conf.FilterConfig interface reflects the filter's configuration and provides methods to access its parameters as well as the enclosing action configuration.

During action invokation, the

public DispatchConfig filter(
  HttpServletRequest request,
  HttpServletResponse response,
  Command command) throws Exception;

method will be called, as the filter is a link in the chain executed by the controller. The remaining chain is represented by the command parameter.

Filters may be configured with a JSP EL expression to be conditionally included into the chain. See the section on Filter Configuration for more on this.

Generally, command filtering can be divided into three optional steps:

  1. command preprocessing,
  2. command execution,
  3. command postprocessing.

Action filters may use the same techniques as servlet filters, including wrapping the request and/or the response.

A filter may decide to not execute the remaining chain. For example, if a filter doing user input validations detected invalid fields, it would want to answer some dispatch configuration to redisplay the last page, rather than continuing with command execution.

Finally, an action filter may inspect (and even replace) the result of the command execution.