No such connector could be found. Resynchronizing client.

I have a problem with Navigator.
If I define an instance of Navigator in my UI ad then I use it, I’ve no problem.
However, if I remove and add views to navigator when I’m going to navigate to a new view, only last execution of servlet works. When I interact with a servlet previously executed, I get a blank screen and in the console of server (Tomcat):

RPC call to com.vaadin.shared.ui.button.ButtonServerRpc.click received for connector 24 but no such connector could be found. Resynchronizing client.

Why does this happen?

How can I fix it?

Help me, It’s very important.

Hi Viktor,

Why do you remove and add views to Navigator dynamically? What is your use case? If you just want to navigate, you should use navigateTo()-method in Navigator.

I remove and add views to Navigator dynamically because I want to change dynamically the object associated to a “navigation state”. I want this because the views are changed from outside, programmatically, a map of parameters is set for them. Is it a bad idea? How can I pass parameters between views? Setting session attributes?

If you want to control what instances are mapped to navigation state you could implement your own ViewProvider and bind it to navigator instead of adding/removing views. Anyway, I’m not sure if that’s needed in your case. If you just want to set a parameters for you view, there is at least two ways to do it in addition to what you have suggested

  1. Add your views as instances to the navigator like navigator.addView(“myview”, myViewInstance) then you can call methods of your view as you wish.

  2. Views can read the parameters from URL. To set those in the code you just add those to the navigation state like navigator.navigateTo(“myview/some/parameter”. You can read the parameters in enter() method of View from event.getParameters().

I also tried to remove and add views before navigation and it seems to work as well. Could you provide some small piece of code which reproduces your problem? Do you modify the UI (views) from another thread? If so you should use either push or polling.

OK, thanks for your answers but I believe I haven’t written a good explanation.

I have the same problem with view providers. You can associate a view object to the navigator with ‘addProvider’ or ‘addView’ methods but the navigation state keeps associated to the view object that exists in the moment you invoke the ‘addView’ method or constructs the view provider. If this object changes later, when you invokes ‘navigateTo…’, the view shown is the object which was associated to the navigation state, not the view with later changes. For that, I change the navigator dynamically. This is what I do (‘navigator’ is the instance of Navigator):

    AppUI currentUI = ((AppUI)AppUI.getCurrent());
    currentUI.navigator.removeView("example");
    currentUI.navigator.addView("example", newInstance);
        
    if (...whatever...){
        newInstance.setDynamicParamsMap(hashMap);
    }
    
    navigator.navigateTo("example");

Doing this, everything works like I want… But only last servlet execution. If I go back to previous servlet execution opened in other folder of web browser, problem initially explained happens.

I also tried this:

- When I define navigator, I add the view:

navigator.addView("example", exampleInstance); - In other place in code, I change programmatically this object:

        AppUI currentUI = ((AppUI)AppUI.getCurrent());
            
        if (...whatever...){
            newInstance.setDynamicParamsMap(hashMap);
        }
        currentUI.exampleInstance = newInstance;
        
        navigator.navigateTo("example");

But this does not work like I want. The view shown is the object which was associated to the navigation state, not the view with later changes.

I have looked for information about passing parameters between view using Navigator but I have not found anything. How can I do this? Isn’t it possible?

You can pass parameters to View via the url but that would be only a string so you have to parse it. Also that would be visible to the user. Another way is to use, for example, VaadinSession where you can store the data.

The second solution you provided does not work because UI and navigator has different view intances. Could you just call currentUI.exampleInstance.setDynamicParamsMap(hashMap) or do you have to create new view instance?

Anyway, I guess your original problem is caused by some another reason than navigator. Did I get it right that the problem occurs if you have mutliple tabs open? What do you exactly mean with “servlet execution”?

No, I don’t have to create a new view instance in order to set a dynamic parameters map. I think problem is Navigator, when you invokes ‘navigateTo’, opens the object registered in the past. This problem would not exist if methods like ‘getProvider’ and ‘getView’ existed in Navigator. My original problem is caused by Navigator class.

I thought changing navigator dynamically was solution to this. But, in this case, only last UI ran as servlet works. If you have ‘http://server:port/app’ open in a web browser and you go to same URL in another folder or web browser, new UI works, but going back to first app, when you interact with this UI disappears and a message like this appears in server console:

RPC call to com.vaadin.shared.ui.button.ButtonServerRpc.click received for connector 24 but no such connector could be found. Resynchronizing client.

Does not any way in order to pass parameters between views using Navigator exist? Only using URL parameters or VaadinSession? I can’t believe it.

When you open your Vaadin app in another tab or browser, new UI instance is created. So, those two should have different navigator and view intances also. It’s very wierd that they interact with each other such a way. Is it possible that you have a static field somewhere?

The other topic:

Modify your code:

[code]
AppUI currentUI = ((AppUI)AppUI.getCurrent());

if (…whatever…){
newInstance.setDynamicParamsMap(hashMap);
}
currentUI.exampleInstance = newInstance;

navigator.navigateTo(“example”);
[/code]To:

[code]
AppUI currentUI = ((AppUI)AppUI.getCurrent());

if(…whatever…) {
currentUI.exampleInstance.setDynamicParamsMap(hashMap);
}

navigator.navigateTo(“example”)
[/code]Then it opens the view with the changes, right?

Right. Problem with Navigator was because of I got a new instance invoking a static method ‘getInstance’. Now, it works well without changing dynamically the navigator But, with two instances of my Vaadin app in two folders of web browser, only last works. If I interact with first, user interface disappears and I get this message in server console:

RPC call to v.v received for connector 8 but no such connector could be found. Resynchronizing client.

My best guess is that you have a static field somewhere in you code such that the two UIs share the same instance of some Vaadin component. That is not supported. One component instance can have only one parent.

That’s OK. Problem was I got instances of my views invoking to static methods ‘getInstance’.

Now, all works perfectly.

I’m very sorry.

Thanks a lot for your help.