Navigation Not Refreshing / Displaying Correctly When Called Programaticall

Got a bit a strange one which I’m looking for help on;

I’ve setup my basic site which displays a login page & then redirects to a ‘home page’ once the user has logged in.

To start with, I simply checked the user had entered a value for both fields, and if so called getUI.getNavigator().navigateTo when the login button was clicked, which works perfectly.

I have now integrated my code with my server, which means I send a message when the user clicks the login button & if the message is successful, I then call getUI.getNavigator().navigateTo when I get the reply.

When I get the reply, I can see that the navigateTo method is called, which triggers beforeLeave() on my LoginView & I can even see the enter() method being called on my ‘home page’ view but the screen doesn’t update & I remain on the login page.

I haven’t changed the navigateTo calls in any way or any of the other code relating toVaadin / views / etc, all I’ve done is move the navigateTo call from the button click to being called from a seperate method.

Any ideas would be great, as I’m so close to actually getting everything up & running so to get stuck now is really frustrating…

The only other piece of information which might be useful, is that I couldn’t access VaadinSession ( it was null ) from this seperate method call either, so I’m wondering if somehow the Vaadin objects / instances are protected in someway, and I need to call it in a different way.

Thanks for getting this far, hopefully it make sense but if you want me to post any code snippets, let me know. :slight_smile:

Little bit more investigation, which will hopefully provide a bit more clarity on my question:

  • if I call this line of code directly from clicking a Button:

( ( NavigatorUI ) UI.getCurrent() ).getNavigator().navigateTo( DefaultView.VIEW_NAME );

  • it works fine

but if I call it from a method after getting a reply from my server, it causes a null pointer exception.

Not sure, but there should be no getNavigator() method (at least not anymore), but only a navigate(...). Could you solve your problem or does it still occur? If 2nd, can you post the related source code?