Configuration Reference

Skip to end of metadata
Go to start of metadata

Stripes requires minimal configuration to get up and running, and zero configuration per ActionBean or page. That said, it is possible to change some of Stripes' behaviour using configuration. The way this is handled is that a Configuration object is responsible for supplying instances of various ConfigurableComponents to parts of Stripes that need them.

When you fire up Stripes without any additional Configuration, Stripes will use an instance of DefaultConfiguration to drive it's configuration. The following sections will walk through how to configure the components of Stripes that are used by default, and how to override those components with custom components developed for your project. Note that while you may supply alternative implementations for any ConfigurableComponent, not all the default implementations have configuration properties of their own.

Initial Configuration

To get up and running all you need to do is configure the Stripes dispatcher servlet, and the Stripes filter in your web.xml. The following shows an example configuration.

Configuring Stripes in your web.xml
<?xml version="1.0" encoding="UTF-8"?>



<web-app xmlns="http://java.sun.com/xml/ns/j2ee"

         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee

         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"

         version="2.4">



    <description>A description of your web application</description>

    <display-name>Your web application's name</display-name>



	<filter>

		<display-name>Stripes Filter</display-name>

		<filter-name>StripesFilter</filter-name>

		<filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class>

	</filter>



	<filter-mapping>

		<filter-name>StripesFilter</filter-name>

		<url-pattern>*.jsp</url-pattern>

		<dispatcher>REQUEST</dispatcher>

	</filter-mapping>



	<filter-mapping>

		<filter-name>StripesFilter</filter-name>

		<servlet-name>StripesDispatcher</servlet-name>

		<dispatcher>REQUEST</dispatcher>

	</filter-mapping>



	<servlet>

		<servlet-name>StripesDispatcher</servlet-name>

		<servlet-class>net.sourceforge.stripes.controller.DispatcherServlet</servlet-class>

		<load-on-startup>1</load-on-startup>

	</servlet>



	<servlet-mapping>

		<servlet-name>StripesDispatcher</servlet-name>

		<url-pattern>*.action</url-pattern>

	</servlet-mapping>

</web-app>

Note that the last piece, configuring a servlet mapping for *.action can be replaced or augmented with any pattern you choose.

Making startup faster
Stripes auto-discovers your ActionBeans at deployment time by scanning your web application's classpath. While this save you from having to enumerate all your ActionBeans somewhere, it can be slow when you have a lot of entries in your classpath. Take a look at the ActionResolver section to see how to speed things up.

Supplying Additional Configuration

In order to keep things simple, there are no external configuration files with Stripes. All of the ConfigurableComponents in Stripes use the same mechanism to find configuration properties. When a property is looked for, it is first looked for as an initialization parameter to the Stripes Filter. If a value is not found there, the property is looked for as an initialization parameter for the Web Application within which Stripes is running. If a value cannot be found there, it is looked for in the Java System Properties.

Unknown macro: {flowchart}

"Stripes Filter Initialization Parameters" -> "Web Application Initialization Parameters"

"Web Application Initialization Parameters" -> "Java System Properties"

It is expected that in 99% of the cases all configuration will be done using initialization parameters for the Stripes Filter, since in most cases you will want to have a single Stripes application per web application. The other two levels become more useful if you have multiple Stripes applications and want to share configuration information across them.

Configuration Configuration

As mentioned above, Stripes uses a Configuration object to drive it's runtime configuration. Two implemenations ship with Stripes. The DefaultConfiguration does not take any parameters itself, but initializes the default implementation for each component, and the components themselves may take parameters. The RuntimeConfiguration uses properties to determine at runtime which component implementations to instantiate. Despite the names, unless you configure it otherwise, Stripes will use a RuntimeConfiguration (DefaultConfiguration is named so because it provides the default configuration information, not because it is the default).

To specify a custom Configuration implementation use:

Property Value Default
Configuration.Class The fully qualified name of a class that implements Configuration net.sourceforge.stripes.config.RuntimeConfiguration

For example, to switch to using your own Configuration, you might make the following change to your web.xml:

Using a different configuration
<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>Configuration.Class</param-name>

        <param-value>com.myco.CustomConfiguration</param-value>

    </init-param>

</filter>

RuntimeConfiguration Properties

The RuntimeConfiguration supports properties for specifying the implementation of each configured component. For more information on what each component is and what it does, click on the links for each of the interfaces. The supported properties are:

Property Value Default
ActionResolver.Class The FQN of a class that implements ActionResolver net.sourceforge.stripes.controller.AnnotatedClassActionResolver.class
ActionBeanPropertyBinder.Class The FQN of a class that implements ActionBeanPropertyBinder net.sourceforge.stripes.controller.OgnlActionBeanPropertyBinder.class
ActionBeanContextFactory.Class The FQN of a class that implements ActionBeanContextFactory net.sourceforge.stripes.controller.DefaultActionBeanContextFactory.class
FormatterFactory.Class The FQN of a class that implements FormatterFactory net.sourceforge.stripes.format.DefaultFormatterFactory.class
LocalePicker.Class The FQN of a class that implements LocalePicker net.sourceforge.stripes.localization.DefaultLocalePicker.class
LocalizationBundleFactory.Class The FQN of a class that implements LocalizationBundleFactory net.sourceforge.stripes.localization.DefaultLocalizationBundleFactory.class
PopulationStrategy.Class The FQN of a class that implements PopulationStrategy net.sourceforge.stripes.tag.DefaultPopulationStrategy
TagErrorRendererFactory.Class The FQN of a class that implements TagErrorRendererFactory net.sourceforge.stripes.tag.DefaultTagErrorRendererFactory.class
TypeConverterFactory.Class The FQN of a class that implements TypeConverterFactory net.sourceforge.stripes.validation.DefaultTypeConverterFactory.class

ActionResolver Properties

The properties in this section affect how the AnnotatedClassActionResolver (the only ActionResolver included with Stripes) functions. The ActionResolver is responsible for finding implementations of ActionBean at runtime. The AnnotatedClassActionResolver does this by searching your web application classpath for all classes that implement ActionBean. While an exhaustive search is guaranteed to find everything, it can be quite slow. In reality your ActionBeans probably all get compiled and placed into the same location in your classpath, e.g. under WEB-INF/classes or WEB-INF/lib/my-project.jar.

Property Value Default
ActionResolver.UrlFilters A comma separated list of URL fragments that restrict the classpath entries that are searched for ActionBeans. For example, "WEB-INF/classes" would search only your web application's classes directory. "myproject" would search any directories or jars in your classpath who's path or name includes "myproject". Empty - search all URLs in the web application classpath.
ActionResolver.PackageFilters A comma separated list of package fragments that restrict that packages searched for ActionBean instances. Unless you package an enormous amount of classes into one location, or have ActionBeans scattered across your classpath, this will provide negligible improvement over a UrlFilter alone. Empty - search all packages.
An Alternative ActionResolver
Starting in Stripes 1.2 a new ActionResolver, the NameBasedActionResolver is available (though not the default). It uses a simple naming strategy to default URL bindings and event names from class and method names (though it still respects annotations when they are present).

ActionBeanContextFactory Properties

The DefaultActionBeanContextFactory allows you to provide an application specific subclass of ActionBeanContext to be used within your application. This is useful as it allows you to isolate yourself from any interaction with HttpServletRequest and HttpServletResponse in your ActionBeans by providing type safe getters and setters for any attributes you need to access in session etc.

Property Value Default
ActionBeanContext.Class The FQN of a class which extends ActionBeanContext net.sourceforge.stripes.action.ActionBeanContext

LocalePicker Properties

The LocalePicker is responsible for picking the Locale under which a request will be processed. In non-localized systems this is usually just the system locale, but in localized systems a match needs to be performed between the list of Locales the user accepts and the list of Locales the server can provide. Properties in this section affect how the DefaultLocalePicker (the only LocalePicker included with Stripes) functions.

Property Value Default
LocalePicker.Locales A comma separated list of locales that the system supports. Each locale can be one to three segments long (e.g. en or en-us or en-us-mac). Either hypens or underscores can be used to separate the segments. The system default locale as returned by Locale.getDefault().

LocalizationBundleFactory Properties

The LocalizationBundleFactory is responsible for providing the rest of Stripes somewhere to lookup localized resources. At present Stripes defines two types of resources - error messages and field names - that may be looked up from the same or different bundles. The properties in this section affect how the DefaultLocalizationBundleFactory (the only LocalizationBundleFactory included with Stripes) operates.

Property Value Default
LocalizationBundleFactory.ErrorMessageBundle The name of a resource bundle. This may by any kind of resource bundle, but will typically be a property resource bundle, in which case the resource files should be available in the classpath. StripesResources which will lead to a file called StripesResources.properties being looked for on the classpath, and potentially locale specific properties files as well.
LocalizationBundleFactory.FieldNameBundle The name of a resource bundle. This may by any kind of resource bundle, but will typically be a property resource bundle, in which case the resource files should be available in the classpath. StripesResources which will lead to a file called StripesResources.properties being looked for on the classpath, and potentially locale specific properties files as well.

File Upload Properties

While there is no file upload component, Stripes does provide an easy way to process file uploads. This section documents properties that affect how the file upload process works.

Property Value Default
FileUpload.MaximumPostSize The maximum HTTP Post size, in bytes, that will be accepted by the server. Note that this is not the maximum file size, but the combined size of all files in a single upload plus any other form fields and headers. In practical terms, this should be slightly larger (say 20-50k) than the maximum file size you want to handle, in order to allow for a reasonable amount of other data to come in the same request. The number is assumed to be in bytes unless a k/kb/m/mb/g/gb suffix is applied. 10 Megabytes.

Validation Properties

By default Stripes will not invoke the validate() method on ActionBeans that implement the Validatable interface if earlier validations (type conversion and annotation driven validation) resulted in validation errors. This behaviour can be overridden:

Property Value Default
Validation.InvokeValidateWhenErrorsExist When true Stripes will call the validate() method regardless of whether earlier validation phases produced validation errors or not. (Introduced in Stripes 1.2) false
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.