Chapter 8. Using RequestFactory

 

This chapter covers

  • Creating RequestFactory-compatible domain objects
  • Generating, editing, and deleting domain objects
  • Handling errors using Java’s Bean Validation framework

GWT provides several ways for your data to communicate between the client and server. In chapter 7 we explored GWT-RPC, which as you saw is a great general-purpose tool that allows you to transport a Java object between client and server. In this chapter we move to a relative of GWT-RPC named RequestFactory. And this raises the question, how is RequestFactory different than GWT-RPC?

GWT-RPC was designed to be a generic service-based mechanism, whereas RequestFactory was designed to work specifically with data objects, which are usually database-persisted objects. So although you can use GWT-RPC with the database, certain aspects of it can make it a difficult fit for your project. Key features of RequestFactory include the following:

  • No shared domain classes, facilitating easier integration with existing projects
  • No servlet to write, and easier integration with dependency injection containers
  • Only data diffs are communicated, providing improved performance

By “no shared domain” we mean that the domain classes live only on the server and aren’t accessed directly by code running in the browser. On the client side you instead use proxy classes, which GWT generates at compile time based on an interface contract.

8.1. Enabling annotation processing

8.2. Understanding RequestFactory architecture

8.3. Understanding the example project in this chapter

8.4. Making calls to the server

8.5. Using custom Locators and ServiceLocators (the “long way”)

8.6. Summary

sitemap