Simplest RPC call maven application, how to

HI guys, I’d like to start from the basics if I may please. I’ve read a few tutorial here and there and I’ve just created a test application with probably the simplest RPC calls you can possibly have (basically I want to use the RPC call to call a method to print a string).
I’m using Eclipse and I’ve created a maven project, loosely based on this tutorial and the following ones
but things are not working very well (forgive me but I’m new to vaadin and still learning java).
This is the structure of my project, including packages:

src/main/java -test_proj.rpc_1 -test_proj.rpc_1.client src/main/resources -test_proj -rpc_1 -MyAppWidgetset.gwt.xml Right, so here is the content of the classes. implements and registers the RPC interface

package test_proj.rpc_1; import test_proj.rpc_1.client.MyComponentServerRpc; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.TextField; public class MyComponent extends AbstractComponent { public String text = ""; private MyComponentServerRpc rpc = new MyComponentServerRpc() { @Override public void setString(String myString) { System.out.println("setString() called. myString is " + myString); } }; public MyComponent() { registerRpc(rpc); System.out.println("MyComponent called"); final TextField name = new TextField(); name.setCaption("another label."); } } still empty at the moment as I’m not sure what goes in it

package test_proj.rpc_1.client;
import com.vaadin.shared.communication.ClientRpc;
public interface MyComponentClientRpc extends ClientRpc
} contains the abstract method I want the RPC call to use:

package test_proj.rpc_1.client; import com.vaadin.shared.communication.ServerRpc; public interface MyComponentServerRpc extends ServerRpc { public void setString(String string); } gets the implementation of the RPC interface and makes the actual call

package test_proj.rpc_1.client; import; import; import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.ui.AbstractComponentConnector; import com.vaadin.shared.ui.Connect; @Connect(test_proj.rpc_1.MyComponent.class) public class MyComponentConnector extends AbstractComponentConnector { MyComponentServerRpc rpc = RpcProxy.create(MyComponentServerRpc.class, this); @Override protected Widget createWidget() { return GWT.create(MyComponentWidget.class); } public MyComponentConnector(){ rpc.setString("My string"); } } contains a component

package test_proj.rpc_1.client; import; public class MyComponentWidget extends Label { public static final String CLASSNAME = "mycomponent"; public MyComponentWidget() { setText("This is MyComponent"); setStyleName(CLASSNAME); } } You’ll notice I left the MyUI class as last, because that’s the one I’m having problems with
In my java experience I’ve learned that to implement a class you have to create an object of that class, but here, being new to the whole framework I don’t get whether I need to create an object for all the classes I’ve used or not. I know that the MyUI init() method kicks everything off, but what then? IN anycase, in MyUI I’ve created a textField and button with the associated click handler. I’ve also created an object of type MyComponent which of course calls the MyComponent() constructor in (the constructor you’ll remember registers the rpc call, print something to the console and creates a new textField which I haven’t attached to the layout as yet.)
So, what do I need to do to get the string printed, meaning how do I get the setString() method executed?

package test_proj.rpc_1;

import javax.servlet.annotation.WebServlet;

import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.annotations.Widgetset;
import com.vaadin.server.Page;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

 * This UI is the application entry point. A UI may either represent a browser window
 * (or tab) or some part of a html page where a Vaadin application is embedded.
 * <p>
 * The UI is initialized using {@link #init(VaadinRequest)}. This method is intended to be
 * overridden to add component to the user interface and initialize non-component functionality.
public class MyUI extends UI {

    protected void init(VaadinRequest vaadinRequest) {
        final VerticalLayout layout = new VerticalLayout();

        final TextField name = new TextField();
        name.setCaption("Type your name here:");

        MyComponent myComponent = new MyComponent();//instantiate MyComponent class

        final Button button = new Button("Open popup");
        button.addClickListener(new Button.ClickListener(){
            public void buttonClick(ClickEvent event){
                //button.setCaption("you clicked me!");
        layout.addComponents(name, button);


    @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
    @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
    public static class MyUIServlet extends VaadinServlet {


Dear Jason.

What I can see is that you only want to implement a very simple API the server offers
to the client, that is, a “ClientRPC”. That is, the client-side (browser) code calls this,
while there is a server-side implementation of setString(String), fine.

Having said that, there is no point you show the UI code asking where to put the
’ setString(“foo bar baz”); ’ call.

This needs to go into client-side code, e.g. in a GWT mouse click handler.