Web Flow

XML Config

The steps to install Hdiv in an application with Spring Web Flow are described below. This configuration is done using xml.

Modify the web.xml file to include the Listener and the Hdiv filter:

<!-- Hdiv Init Listener -->
<listener>
    <listener-class>org.hdiv.listener.InitListener</listener-class>
</listener>
<!-- Hdiv Validator Filter -->
<filter>
    <filter-name>ValidatorFilter</filter-name>
    <filter-class>org.hdiv.filter.ValidatorFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>ValidatorFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

Map the filter to Spring MVC Servlet so that Hdiv can process all requests first.

It is important that Hdiv's Listener should go after Spring's Listener ContextLoaderListener.

Add dependencies

Add the required dependency libraries to your pom.xml file:

<dependency>
    <groupId>org.hdiv.ee</groupId>
    <artifactId>hdiv-ee-config</artifactId>
    <version>${org.hdiv-ee-version}</version>
</dependency>
<dependency>
    <groupId>org.hdiv.ee</groupId>
    <artifactId>hdiv-ee-spring-mvc</artifactId>
    <version>${org.hdiv-ee-version}</version>
</dependency>

Add the Hdiv configuration

Add hdiv-config.xml file to the other Spring configuration files:

<!-- Spring Context Loader -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/dataAccess-config.xml
        /WEB-INF/security-config.xml
        /WEB-INF/hdiv-config.xml
    </param-value>
</context-param>

Create the Hdiv configuration file.

This file is an XML file that follows the format of Spring configuration files.

For convention, its name should be hdiv-config.xml, located in the WEB-INF directory and its minimal content is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:hdiv="http://www.hdiv.org/schema/hdiv-ee"
xsi:schemaLocation="http://www.springframework.org/schema/beans
[http://www.springframework.org/schema/beans/spring-beans.xsd](http://www.springframework.org/schema/beans/spring-beans.xsd)
[http://www.hdiv.org/schema/hdiv-ee](http://www.hdiv.org/schema/hdiv-ee)
[http://www.hdiv.org/schema/hdiv/hdiv-ee.xsd">](http://www.hdiv.org/schema/hdiv/hdiv-ee.xsd">)

    <!-- Hdiv Base Configuration -->
    <hdiv:config excludedExtensions="css,png,gif,js,woff">
        <hdiv:startPages>/</hdiv:startPages>
    </hdiv:config>

    <!-- Own Editable Validation -->
    <hdiv:editableValidations>
        <hdiv:validationRule url="/.*" />
    </hdiv:editableValidations>
</beans>

Configuration of Spring Web Flow

Add this bean to the Spring Web Flow config:

<bean id="validator" class="org.hdiv.web.validator.EditableParameterValidator">
    <property name="innerValidator">
        <bean class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>
    </property>
</bean>

And add the following validator:

<mvc:annotation-driven validator="hdivEditableValidator"/>