concept GWT in category seam

appears as: GWT
Seam in Action

This is an excerpt from Manning's book Seam in Action.

Aside from their residence in the Java EE 5 specification, the two architectures just mentioned share little resemblance, their backs facing each other like two sides of a coin. This communication barrier casts a shadow on the tremendous potential of each technology. While it’s true that developers are able to get these two Java EE tiers to work together, it requires a lot of “glue” code. Seam absorbs that responsibility and fits JSF and EJB 3 together, thus ironing out one of the roughest spots in the Java EE 5 specification and completing the missing link in the evolution of the Java EE platform. As such, Seam has positioned itself as the prototype for future Java EE specifications. So far, three Java Specification Requests (JSRs) have been accepted: JSR 299 (Web Beans), JSR 314 (JavaServer Faces 2.0), and JSR 303 (Bean Validation). Seam isn’t married to JSF or EJB 3, as figure 1.2 suggests. You can swap in alternative view technologies such as Wicket, Tapestry, GWT, and Flex in place of JSF, though understandably with less accord. In the business tier, Seam supports the use of JavaBeans as transactional components and also boasts integration with the Spring container, both of which are arguably better choices than EJB 3.

GWT is an Ajax-based framework that allows you to develop your web application purely in Java, without having to write HTML or JavaScript. It offers a similar value proposition as Ajax-based JSF libraries, but replaces the declarative UI with Java constructs. The toolkit compiles your Java code down to JavaScript, which means that you don’t have to go through the pain of coding JavaScript and you can be confident that the JavaScript is delivered to the browser in the most efficient manner possible.

GWT’s remote procedure call (RPC) mechanism is designed to allow a GWT client application to access server-side business components via Ajax. In the GWT tutorials, you are told to use a Java servlet to handle the request. However, in this section, I show you how to hook one of these RPC calls to a @WebRemote method on a Seam component. We refactor the Trivia component so that it can act as a remote service to GWT, giving GWT access to the trivia questions in the database. Seam’s GWT integration uses Seam remoting, so be sure to have the Seam resource servlet installed when using this integration.

12.6. Responding to GWT remoting calls

As you lean more toward the single-page application, you may reach a point where JSF just doesn’t fit any longer. If that’s the case, you are probably better off moving to a UI framework that’s designed around the use of remoting calls. One such library is the Google Web Toolkit (GWT). A move from JSF to GWT doesn’t mean that you have to leave Seam behind. GWT is intended for creating the user interface, which means it must delegate work to transactional components on the back end. Seam remoting can establish that bridge.

This section is focused on the integration of Seam and GWT, not on GWT fundamentals. If you are a novice to GWT and are seeking in-depth information on the subject, I encourage you to pick up a copy of GWT in Action (Manning, 2007). Once you’re comfortable with GWT, or if you’re just interested in finding out how the integration works, forge ahead.