Google Web Tools, A Starting Point has been edited by Daniel Carleton (May 20, 2007).

(View changes)

Content:

GWT and Wicket

Introduction

Wicket and GWT are both component-oriented web application frameworks, but they take opposite approaches to state management. Wicket pages and sessions are composed and maintained entirely on the server, and a round trip takes place when reflecting any significant changes to them in the browser. GWT pages, on the other hand, are composed of _javascript_ widgets running on the client-side, where state is maintained and ongoing server communication occurs against a flat RPC layer.

Motivation

Why would you want to include GWT widget as components in your Wicket pages?

Language Consolidation

A compelling aspect of Wicket its lack of any JSP _expression_ language equivalent. Page logic is instead implemented in Java code, allowing full use of standard development tools. GWT offers the same advantages with its Java -> _javascript_ compiler. All widgets are implemented, tested, and debugged in Java code before being compiled to _javascript_ for deployment. Marrying GWT and Wicket would allow for further language consolidation by removing the need to write _javascript_ without sacrificing rich client-side behavior.

Client-side State Can be Nice

Server round-trips can be heavy for implementing some types of client-side behavior. For example, what if you're tracking the coordinates of a mouse-over on an image. Doing a round-trip to check the mouse cursor location against some state on the server would be prohibitive. What if you could simply ship the Java code for those checks and their associated state to the client?

Starting Point for Integration

I began designing an integration between Wicket and GWT, but never followed through to implementation. I concluded that including GWT in some kind of cohesive development environment with Wicket was taking too much work. This may improve with an incremental Eclipse builder for GWT.

Class Diagram

This class diagram captures the design of a potential integration between Wicket and GWT.

Discussion

Create a central abstract class to represent your GWT widget as a Wicket component: GwtWicketComponent. This class implements a Wicket listener for RPC calls from the widget running on the client, and subtypes of GwtWidgetComponent like FooComponent provide and implementation of RemoteServiceServlet for fielding the calls.

GwtWidgetComponent extends Panel, and should have some associated markup that includes the container for your GWT widget. GwtWidgetComponent will automatically add an appropriate callback URI to an attribute of this container, which the client-side code must use to invoke RPC calls.

A special GwtRpcTarget implementation of IRequestTarget transports the RPC response payload back to the client via Wicket's standard RequestCycle.

Reply via email to