Extensions
Extensions - how to extend and customize Stripes
Beginning with Stripes 1.5, you can configure one or more packages in web.xml
from which Stripes will automatically load all extensions. Extensions include:
- all classes that implement subinterfaces of ConfigurableComponent
- custom TypeConverters
- custom Formatters
- Interceptors
In web.xml
, add an initialization parameter to StripesFilter
called Extension.Packages
. Each package that you indicate automatically includes all sub-packages, so do not use .*
. For example,
<filter> <display-name>Stripes Filter</display-name> <filter-name>StripesFilter</filter-name> <filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class> <init-param> <param-name>ActionResolver.Packages</param-name> <param-value>net.sourceforge.stripes.examples</param-value> </init-param> <init-param> <param-name>Extension.Packages</param-name> <param-value>net.sourceforge.stripes.extensions</param-value> </init-param> </filter>
Now you can drop in Stripes extensions to net.sourceforge.stripes.extensions
and its subpackages, and they will automatically be loaded. You can also use more than one package root by separating the packages with commas:
<filter> <display-name>Stripes Filter</display-name> <filter-name>StripesFilter</filter-name> <filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class> <init-param> <param-name>ActionResolver.Packages</param-name> <param-value>net.sourceforge.stripes.examples</param-value> </init-param> <init-param> <param-name>Extension.Packages</param-name> <param-value>net.sourceforge.stripes.extensions, another.pkg.extensions</param-value> </init-param> </filter>
If you have a class in an extension package and want to tell Stripes not to automatically load it, you don't have to move the class to another package. You can simply annotate the class with @DontAutoLoad.