General architecture question - update UI with no request to server

I have used vaadin for a few personal projects and I think its great! I am trying to get my company to start using it, but the architects have raised a good question that I didn’t know the answer to. My company has a heavily trafficked website, and there is concern over scaling vaadin as it appears every request, even simple requests to change the client UI result in a round trip to the server.

For example, lets say I have a basic button that I want to change a label when clicked:

button1.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
button1.setCaption (“New Caption!”);

When button1 is clicked, a server request is generated, the server responds and tells the client UI to change the caption. I realize that most events will need a server to do something, but there are a few things in our application that are just label changes and other client-side-only things that we don’t want to result in a server request. In our current application, a simple javascript handler manipulates the dom and updates the label.

Is it possible to have a “client only” listener on events?

Currently not.

I played with this idea a few months back, tried to create an add-on that would allow basic stuff like changing the caption of a button in the client. But in order for this to happen in a generic fashion, some sort of pseudo-event-language must be created that is transfered over to the client and is then re-interpreted to actual event actions there. If someone has a better approach, please share.

There are several limitations in this approach, such as data integration (everything must be copied when the listener is created, no updates after that, so the event actions can’t depend on the server state). Even simple stuff like checking whether a checkbox is checked in the client will prove out to be very hard, since Vaadin’s client side components don’t have a proper API yet. And I bet some reflection would have to be used in the server when constructing the event handlers, since you need to know which operations are safe to perform in the client.

Anyway, I think it would be truly great if we could pull this off, but I don’t see it happening with a Java-centric framework. If we would be working with JavaScript in both the server and in the client, things would be different (I actually have a working prototype of this).

And for now, the correct solution (and maybe the right and the best solution as well) is to satisfy these needs using pure GWT.

You can also create your own Vaadin widgets for any critical parts where you do not want to have the unnecessary roundtrips - as you write widget using GWT, you can handle and fine-control on which variables gets sent to server and when.