Skip to content

GWT Integration Spring Context

apetrelli edited this page May 3, 2013 · 3 revisions

The gwt-integration-spring-context helps to integrate GWT and the context-related part of Spring, with no connection to a servlet-based environment.

The problems

The solutions

RequestFactory should use Spring-managed services

The problem: Suppose that you use RequestFactory against a service layer. The services should be taken from the Spring context.

The solution: Use GwtServiceLocator.

Inspired by Spring Roo, the GwtServiceLocator must be configured in your request annotation:

@Service(value = PersonService.class, locator = GwtServiceLocator.class)
public interface PersonRequest extends CrudRequest<PersonProxy, Long> {
...
}

If you are under a servlet environment you need also to:

  • use CustomServiceLayerDecorator in your custom RequestFactoryServlet;
  • use SpringWebApplicationContextHolderListener.

The validator should be a Spring-managed bean

The problem: The Bean Validation validator should be taken from Spring Context.

The solution: Use CustomServiceLayerDecorator in your custom RequestFactoryServlet.

Client and Session locale are not in sync

The problem: GWT Client locale (via the "locale" parameter) and the server locale are not in sync usually. This is useful for server-generated messages, like server-side validation.

The solution: Transmit the locale by using LocaleRequest.

TODO: WE NEED AN EXAMPLE BEFORE COMPLETING THIS DOC.