Dwain Wuerfel
Dwain Wuerfel

Reputation: 373

Use of viewScope: is this an Issue or by Design

I was recently developing an XPage that had an inputText control using a viewScope as the value. Below is the initial XPage name being used:

xpNewOrderFax.xsp

and this shows the viewScope values:

viewScope values listed for xpNewOrderFax.xsp

now when I switch to this Xpage:

xpRequest.xsp

the viewScope value for AccessNumber is not listed as expected:

viewScope values listed for xpRequest.xsp

So, now you would think that since the viewScope value for the AccessNumber has been removed from the viewScope map that if I return to the xpNewOrderFax.xsp page I would have to re-type my value. However, that is not what occurs. The viewScope value is listed once again as shown:

viewScope value for AccessNumber is listed

My question is whether this is an issue or by design because it was my understanding that a viewScope is available until you leave the current XPage. I have been able to get a co-worker to replicate this issue where the viewScope value disappears when leaving the current XPage and re-appearing when returning to the XPage. In the XPages Portable Command Guide on pg 213 it sounds like this is by design, but then on pg 215 it sounds like it is an issue. There is no value set for the application or session timeout settings on the XPage properties page.

Hopefully, someone can clarify this not only for me, but the many others using this research outlet.

Update at request of Per: This is the code for the inputText control and I did a search to be sure I wasn't doing a viewScope.put("AccessNumber") or a viewScope.get("AccessNumber") anywhere else.

ccDuplicate Access Number

I didn't use the browser Back button when discovering this. I am using an outline entry, code below, to navigate from one page to the other, then a tab in the OneUI layout, property settings below, to navigate back.

ccOutline_Admin OneUI Layout

Upvotes: 1

Views: 710

Answers (1)

Jesse Gallagher
Jesse Gallagher

Reputation: 4471

I think Mark's comment is likely on the right track: if you go back in the browser and continue using the older page, you'll probably pick back up on the older page instance. The viewScope is tied to a combination of the page name (e.g. "/xpNewOrderFax.xsp") and the $$viewid value (e.g. "!dsk58bqeqm!"), and so the viewScope lives on the server for a little while after the user leaves the page, since the server doesn't know if the user is going to come back to it. If you visit another page and then go back in the browser to the previous one, it could resurrect the sleeping ID-keyed instance of the page and pick back up where it was, viewScope and all.

I suppose the same could also happen if you're in an environment where the initial page load is overly cached and it doesn't even re-fetch a new instance from the server on a new GET, but that would be a network/proxy/browser problem more than something with Domino.

Upvotes: 1

Related Questions