Simple GWT Spring Webapp

David Winterfeldt

2008


This enhances the Spring Web Flow Subflow Webapp by using GWT (Google Web Toolkit) version 1.5-RC1 for a GWT table widget on the search page. The example also uses Spring JS to submit the person form by using Spring.remoting.submitForm to only update the content div. Tiles Spring MVC Module (version 1.1) has been updated to support rendering Tiles fragments like AjaxTilesView and FlowAjaxTilesView in Spring JS and Spring Web Flow.

View a working demo of the application at http://www.springbyexample.org/simple-gwt/.

1. Web Configuration

All JSP requests are routed to '*.htm' and all '*.do' requests are requests to a GWT Controller. Previous examples mapped requests to '*.html', but this caused a problem serving the autogenerated GWT HTML pages. It might be better to have the controller map requests to specific areas like '/person/*.html' and then this would avoid the conflict between serving dynamic and static content.

Excerpt from /WEB-INF/web.xml
                
<?xml version="1.0" encoding="UTF-8"?>
<servlet>
    <servlet-name>simple-form</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value></param-value>
        </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet>
    <servlet-name>gwt-controller</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
</servlet>
    
<!-- Map all /resources requests to the Resource Servlet for handling -->
<servlet-mapping>
    <servlet-name>resources</servlet-name>
    <url-pattern>/resources/*</url-pattern>
</servlet-mapping>
    
<servlet-mapping>
    <servlet-name>simple-form</servlet-name>
    <url-pattern>*.htm</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>gwt-controller</servlet-name>
    <url-pattern>*.do</url-pattern>
</servlet-mapping>