Client-side / Server-side

Hello everybody.

I am familiarizing myself with Vaadin and I have a question I did not find any answer in the Book of Vaadin. I am french so please be soft on me if I missed the information (and for my english xD).

What I want to know is : How does the compiler know what it has to compile in javascript (the client-side) and what it has to compile in java (the server-side).

I know GWT, by convention, has 3 packages (+ XML configuration file) : Server, Client and Shared and thanks to these package the compiler know how to compile.

How does Vaadin work ?

Thanks for all.
FH.

In Vaadin the client-side is called a “widget set”. This reflects to the fact that the widget set implements rendering and used event handling of the user interfaces components.

Widget set is compiled with GWT to JavaScript. All of the rest stays server-side.

vaadin.jar includes a precompiled javascript for the default widget. Thus no GWT compilation is needed at all when you limit yourself to the default widget set. If you want to add your own widgets, use widget add-ons from
http://vaadin.com/directory
or decide to leave some of the default widgets out the widget set or defer their loading to a separate javascript file, you must recompile the widget set.

Widget set is defined in YourWidgetset.gwt.xml. If defines which widget set is inherited to your widget set. This file doesn’t have to explicitly list the widgets you want to include. Instead, GWT compiler looks for @ClientWidget annotations in your project (server-side) to figure out what widgets to include in your widget set.

For more details on how this works, see
http://dev.vaadin.com/wiki/WidgetSet
.

I am using the basic widget set first ^^.

So if I understand well, there is nothing to do ? The compiler compile the widgets belonging to the Widget Set in javascript (then will be run in the client) and all the rest is compiled in java (then will be run in the server) ? Even if all the code is done in the same class ?

If that’s true, Vaadin roxx a lot ^^.

As long as you are using the default widget set, there is nothing to do. It just works. You do not even need a gwt compiler.

You can not mix server-side and client-side code to the same class - all of the code you write is run in server. If you want to extend the framework with new widgets, then client-side half of those widgets will get compiled with GWT and run in client. If you want to experiment, just add an add-on to your project. If you are using eclipse, it will ask automatically if you want to re-compile the widget set…

All the code I write is run in server ? But what about the javascript ?

Supposing I am using the default WidgetSet, when I write something like :

Button myButton = new Button("MyButton", new ClickListener()
{
	@Override
	public void buttonClick(ClickEvent event)
	{
		...
	}
});
mainWindow.addComponent(myButton);

The button will be generated in javascript and run in the client. But when I click on, the “business code” (I am not sure about the translation, I mean the interaction with the model), it will be run in javascript or in the server ?

I’m sorry to not understand well …

It will be run in server.

Ok.

Thanks for all Joonas.