Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Client-side and server-side components

Bart B
1 decade ago Sep 18, 2011 9:29pm
Jens Jansson
1 decade ago Sep 19, 2011 6:05am

Hi!

What pure GWT does is that it converts all your java code into javascript that can be shown in the browser. What Vaadin does is it creates readymade widgets with GWT and then has a server counterpart that instructs the client side on how it should be painted and behave. The server side doesn't say in any way what the component should look like, it just contains the state of the component. What is great with this approach is that you can build up applications without recompiling the javascript all the time - you just instruct the server side component and the precompiled client side code will take care that it looks the way you want. Another benefit is that you have no business logic code inside the browser. Another benefit is that every action the user takes produces just a message about it to the server, like the user pressed button x, or the user entered the text 'abc' in textfield y, instead of calling a specific method. A downside is that it has to visit the server on every action the user takes.

A case like your isVisible() -toggling button is something I would definitely handle on the server side, as you have all the capabilities there. The cases when I go modify the client side, which is quite rare, is when there is no ready made widgets that can take care of my use cases, like adding a listener as you said. I might consider implementing something in the client side as well if the component I'm looking for is very roundtrip -heavy.

The communication between the server and client is quite simple. The server has one method to send all the variables to the client side and one method to get responses from the client, and the client side has one method to receive all the variables from the server. You can basically convert any GWT widget into a Vaadin widget by implementing a one-method-interface in it, and implementing a server counterpart to it.

Not sure if I answered your questions, but I'll try to answer them if you have anything more to ask.

Henri Sara
1 decade ago Sep 19, 2011 10:05am
Alexander Pchelintsev
1 decade ago Sep 19, 2011 11:17am
Bart B
1 decade ago Sep 20, 2011 9:17pm
Bart B
1 decade ago Sep 20, 2011 9:42pm
Alexander Pchelintsev
1 decade ago Sep 21, 2011 10:34am