Over a million developers have joined DZone.

Web Frameworks: Comfort vs. Expediency?

DZone's Guide to

Web Frameworks: Comfort vs. Expediency?

· Java Zone ·
Free Resource

Get the Edge with a Professional Java IDE. 30-day free trial.

Two nights ago I had a conversation with Craig McLanahan, among others, in a slightly dubious sports bar near the JavaOne conference site. When the subject of web frameworks came up, an interesting, and probably obvious, angle emerged.

For those who don't know (which, in this case, suggests you're not actually a web framework developer), Craig is the creator and thinker behind several frameworks, such as Struts and Shale. The discussion turned to "web frameworks out there", where Craig's argument turned on the usefulness of pre-packaged components in the real world. JSF components, together with the various extensions to JSF, would on this basis be much preferred to anything where the developer needs to do any kind of coding. To really drive this point home, let's look at integrating Google map into a web application. Google map, which is really the ultimate AJAX widget, can be introduced as simply as follows, via the RichFaces framework, which extends JSF:

<rich:panel header="Google Demo">
<rich:gmap />

That's all. We can then add a slider that will zoom in/out, by adding another component, as shown below:

<rich:panel header="Google Demo">
<rich:gmap />
<rich:inputNumberSlider width="400"
id="zoom" showInput="false" minValue="1"
maxValue="18" onchange="map.setZoom(this.value)"/>

Simpler is hard to imagine. On the other hand, you have little control over the component, while simultaneously not feeling very comfortable as a Java developer. Tag libraries and JSPs are poison to many programmers. Both GWT and Wicket offer a much more comfortable environment, since you're coding directly in Java. Here, for example, is how one might go about it in Wicket:

final GMap gMap = new GMap(new GLatLng(0d, 0d), 1);
GLatLngBounds bounds = new GLatLngBounds(new GLatLng(-90, -180),
new GLatLng(90, 180));
// Create panel to hold the GMap:
gMapPanel = new GMapPanel("gmap", gMap, 440, 450, "yourSiteKey"));
GMapListener listener = new GMapListener() {
public void onClick(AjaxRequestTarget target, GMap arg1) {
// User has ended a map move, need to update map,
// but clear all the markers first:
gMap.addOverlay(new GMarker(new GLatLng(0,0),
new Label("info","heey thats my marker")));

The above code is from this document, which may be slightly aged. Whatever the case, the above would be more or less how a GMap panel would be defined in Wicket. Next, you would add that GMap definition to a component, such as a Wicket panel, via code such as the below...


...and then add a Wicket tag to the matching HTML file:

<div wicket:id="gmap"></div>

Wonderful, if you're a Java developer. However, isn't the simple RichFaces component far more attractive, when you're thinking about "time to market" and similar terms? Does this not doom GWT and Wicket, and projects that attempt similar approaches, to being adopted by only a very small subset of companies in the real world? Perhaps, therefore, the buzz around GWT and Wicket only exists because those creating that buzz are very vocal and very visible people who are online a lot, far more than the corporate developer quickly composing their web apps via predefined JSF components? Maybe one also hears less from them because they have less problems, since their components simply work, meaning that there's nothing to cheer or complain about online. What do you think? Are Java programming models on top of technologies such as AJAX a waste of time? Isn't the user community better served with prepackaged components that they can simply plop on their page?

Get the Java IDE that understands code & makes developing enjoyable. Level up your code with IntelliJ IDEA. Download the free trial.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}