This forum is closed to new posts and responses. New discussions are now taking place in the IBM Developer Answers forum.

Oct 23, 2015, 5:32 PM
2 Posts

Problem with session variable

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 9.0.1
  • Role: Developer
  • Tags: PartialRefresh
  • Replies: 5

We have sessions variable loss problems. This causes non-response from the server side code and a lot of partial refresh problems.

These problems occur unsystematically, especially if no operation is performed on the page  for a few minutes..

These are the only issues observed during our developments but these are really blocking issues.

Did you have already noticed this problem ?

Thanks a lot.

Oct 24, 2015, 1:12 PM
453 Posts
I use sessionScope all the time but ....

If a sessionScope is "lost" it might be that you had inadvertently moved away from the session then returned. If you are switching databases during your processing then you might well be creating a new session. To get around this I have all XPages controls (XPages, Custom Control) in the same database. I can therefore open an new XPage with a datasource from a second DB and always stay within the same XPages Session. If your URL opens a different DB it creates anew session.

I hope I got your question right, if not please expand on your question (ie where/when) might need a whole bunch more info. 

Oct 26, 2015, 1:40 PM
2 Posts
More info....

I can now reproduce the problem.

I have a xPages which create a new document and open another xPages to edit it. (The new xPages is opened in a new browser window/tab).

I work on the new xPages, some partial refresh are executed and I save it.

I dont' close the browser window, I just focus on the first xPages. All actions on this first xPages with any code on server side have no response.

It's like if the reference on my xPages on the server has been lost. Il see on the debug firebug the request on the server but no response.

Any idea ?

New thanks a lot.

Oct 28, 2015, 3:43 PM
453 Posts
when you open the new browser instance ...

as I understand the scoped variables, a session is a single instance of the browser/database. By opening a new browser instance even in the same database initiates a new session so all existing sessionScope variable are lost and a new set created for the new instance. Why do you need to open a new instance of the browser? In XPages it is fairly simple to define multiple dataSources to a single page. In several instances I display one or more documents from different databases on a single XPages. So if I understand your issue correctly why not add a panel to your original XPages with a button or ??? that causes the Panel to be rendered and add the CRUD fields in the panel. Then on the panel have a save button that writes the dataSource to disk and sets the rendered property of the panel to false. I think the new browser instance is really hard to control and fairly inefficient when compared to doing a partial refresh on the panel. Plus the user can go to the second window instance and just switch back to the original window and you have no way of knowing if they did anything in the second session.

If you are committed to doing it the way that you are then clearly sessionScope variables would not work. You could probably do it using applicationScope but then you would have to write the logic to clear them because they may hang around for a long time. I have considered using applicationscope variables to "remember where the user was last tiemthey were in the application, but have never really pursued this option. 

Oct 29, 2015, 9:07 AM
589 Posts

I'm not sure if I'm totally following this but here's my thoughts on sessionScope...

I try to avoid using sessionScope these days.  It's great for somethings...  a shopping cart object for instance that is useful no matter what page the user goes to.  It's not very useful in my opinon for anything page specific or navigation specific.

Remember sessionScope is not really "USER" scope - it's browser scope.  So if you have user "A" logout it's possible that user "B" could login and still get some of user "A"'s scope variables with data.

As for this timeout issue that Vincent is getting...  I'm not sure what that is..  I have seen, and Paul Calhoun has posted here about it...  you can do an action which will then screw up future partial refreshes on the page.  I forget the details but it's usually has something to do with triggering an XAgent.  There's a way to correct it of course...  I just forget.  Again he's posted in this forum about the issue.  I'm not saying that's in play here, just the first thing that comes to mind...



Oct 30, 2015, 6:21 PM
453 Posts
yes you can get some residual sessionScopes

That is why in my logout action I call this little function:

function clearMap( map:Map ){ // Get iterator for the keys
      var iterator = map.keySet().iterator();  // Remove all items 
      while( iterator.hasNext() ){  
        map.remove( ); 

and I call clearMap(sessionScope) before logout. I have never experienced any issues doing this but may be missing something.

This forum is closed to new posts and responses. New discussions are now taking place in the IBM Developer Answers forum.