How to configure Vroom for Struts Application

2008-07-01
2013-04-11
  • Farrukh Ijaz
    Farrukh Ijaz
    2008-07-01

    To make Vroom work for Struts application, you need to tell VroomFilter to intercept *.do URIs. Add the following configuration in web.xml of the application.

    <filter>
        <filter-name>VroomFilter</filter-name>
        <filter-class>net.openkoncept.vroom.VroomFilter</filter-class>
        <init-param>
            <param-name>config-file</param-name>
            <param-value>/WEB-INF/vroom-config.xml</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>VroomFilter</filter-name>
        <url-pattern>*.jsp</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>VroomFilter</filter-name>
        <url-pattern>*.html</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>VroomFilter</filter-name>
        <url-pattern>*.do</url-pattern>
    </filter-mapping>
    <servlet>
        <servlet-name>VroomController</servlet-name>
        <servlet-class>net.openkoncept.vroom.VroomController</servlet-class>
        <init-param>
            <param-name>upload-file-size-threshold</param-name>
            <param-value>1024000</param-value>
        </init-param>
        <init-param>
            <param-name>upload-file-temp-folder</param-name>
            <param-value>/WEB-INF/temp</param-value>
        </init-param>       
    </servlet>
    <servlet-mapping>
        <servlet-name>VroomController</servlet-name>
        <url-pattern>/vroom</url-pattern>
    </servlet-mapping>

    In the vroom-config.xml file, for webpage definition, instead of using the *.jsp page uri, you should use the *.do uri for the pages which are defined in struts-config.xml as part of action mapping. E.g.

    <webpage uri="/login.(jsp|do)">
        <form id="loginForm" method="login" bean-class="com.myco.demo.form.LoginFormBean" var="loginForm" scope="session">
            <element id="username"/>
            <element id="password"/>
        </form>
    </webpage>

    Note: in the form definition, if you want to set/get the values in a struts form-bean, you need to specify the form-bean class and the same variable name which is used in struts-config.xml file to access the bean.