vaadin7: session and requestparamaters

im writing a small app in vaadin 7.

when the user his refresh I dont want the user to be logged out so I have

@PreserveOnRefresh on my UI

Works fine. The page can be refreshed and user is still logged in. I was hoping what when I open a new browser Tab the user would still be logged in but I guess that I will have to code my self using cookies? Or any other way?

Next problem. When I open http://localhost:8080/?pid=5 I can ofcause get the PID paramater in the UI.init method but this way I will not pick up the change if the user then enters (or gets the URL from other source) say http://localhost:8080/?pid=6.

So I subclass VaadinServlet and overwrite service method. Now I can see the change in the PID paramater of the request URL in this method… but I cannot access the VaadinSession.getCurrent since its allways NULL, and im not sure whats the best way to communicate the thange of the reuest paramater to the vaadin application.

any pointers to solutions to the 2 problems I have?

  1. yes, cookies should do the trick

  2. VaadinSession.getCurrent only works when you are in the main thread of the application, otherwise you need to ask the session from any attached component or UI directly, or save a reference to the session to a variable that can be accessed from the background thread. Note: same goes for UI.getCurrent.

thanks, I fixed it with cookies. I will look at the 2. options at some point for learning.