Blog

Framework’s client-server communication simplifies your life

By  
Leif Åstrand
Leif Åstrand
·
On Mar 27, 2017 7:10:00 AM
·

One unique feature of Vaadin Framework is the way it automatically manages communication between the user's browser and your server. The biggest benefit of this is not directly related to communication, but rather that you can use a very productive programming model.

Programming model

Without the Framework's communication support, your programming model choices would either be a thin client or a thick client. Thin client is just a fancy way of saying that all your UI logic runs in your web server and the only communication is when the web browser requests a new full HTML page to show. Thick client is the opposite of this: the client can be a desktop application, a native mobile app or a JavaScript application running in a web browser. The UI logic is then running in the client, but it still needs to asynchronously communicate application data to and from your server, which takes care of things like security, as well as accessing a database or some other backend service.

The programming model of Vaadin Framework instead combines the strengths of each model. From the thin client model, you get direct access to your backend services since the application's UI logic runs on the server. At the same time, you get the main thick client benefit of a responsive application that doesn't need to reload the page every time the user does something. On top of this, there's also the wide range of available UI components that make it possible to build a web application without having to learn and understand web technologies, such as JavaScript and CSS.

Security

Security is another area where the communication features and programming model are very useful. Thanks to those, the framework provides automatic protection against vulnerabilities, such as cross-site request forgery, while the built-in components take care of cross-site scripting unless explicitly configured to render data as HTML. The framework can also ensure that a component that is disabled or completely removed from a view will not be able to accidentally receive any messages from a malicious client. These are things that you might have to take care of manually with other programming models.

Component integrations

The situation where you're most directly using the communication features of the framework is when you create a custom client-side component implementation. For communication between the client-side and server-side part of your component implementation, you can simply define a Java bean that holds any server-side data that should be available on the client and use regular Java interfaces for doing RPC in either direction. The framework takes care of converting your data to JSON before sending it over the network and then converting it back at the other side. It also keeps track of the URL to use for sending HTTP requests and internally routing each message to the right component. Using the same Java class or interface definition on both sides also means that the sides will always be in sync when refactoring.

Server push

One final noticeable feature is server push. A typical web application works so that communication only happens when the browser sends a request to the server and the server returns a response to that request – the server cannot initiate the contact. This is no problem, if communication is only needed for reacting to user input. The situation changes when the user is only passively waiting for updates from the server, e.g. progress updates for a slow batch job, or receiving new messages to an inbox or a chat window. With Vaadin Framework, you only need to add the @Push annotation to your UI class. The framework then automatically takes care of establishing a bi-directional communication link and keeping track of when to send messages.

Summary

As you have seen, there are several areas where the communication functionality in Vaadin Framework helps you create applications that serve your users. The most important area is the programming model that combines the main benefits from both thin and thick client architectures. Other important areas are security, integration of client-side components and the turnkey server push support.

Try Vaadin Framework
Leif Åstrand
Leif Åstrand
Leif Åstrand keeps an eye on the overall architecture of the Vaadin platform. He knows a thing or two about how Vaadin, Web Components, and the internet works.
Other posts by Leif Åstrand