1
votes

Trigger full refresh when logged out in 8.5.3. I don't care if the data is lost, I just want to trigger full refresh if partial refresh fails in case user is logged out or session has timed out.

I have two windows open. If I press the logout button on window 2, and then come back onto window 1 and try to do a partial refresh, it returns nothing (just blank value for that control). So how can I trigger a full refresh when the user is logged out?

I tried onComplete, onStart and onError client side events, but cannot figure out how I could find out when this logout has happened, I tried the following code:

var strUserName = '#{javascript: @Name("[CN]", @UserName());}';
alert("Start: " + strUserName);

It always returns the username rather than anonymous in window 1, even when user is logged out in window 2!

onError event never fires when partial refresh fails or returns blank value.

Any ideas or help would be greatly appreciated.

2

2 Answers

1
votes

Did you try to lock the database down (Anonymous = NoAccess)? Then you should get an 404 and the error routine fires.

Update

You can:

  • add a redirect meta header to the page that kicks in when a session expires (cheapo solution, but might catch already most used cases)
  • Still lock down the database but give Anonymous the right "view public pages" and then have the page(s) that anonymous is allowed to see marked with the attribute "available for public access"
  • Make sure your partial refresh checks if nothing comes back and reloads the page then (most work since you need to alter business logic) - some sample of your code would be needed
1
votes

onComplete has one weakness. The value bindings are evaluated when the page is rendered, not after a partial refresh, as you might think. This is due to the way the request works. When a request is sent, the callbacks for the request are bound (onStart,onComplete, etc.). Therefore the client side handler code has to be available before the refresh happens.

If the partial refresh doesn't refresh the item with the event handler(onComplete/onStart/onError), I think the value binding is only updated on page load.

There are several ways to solve this.

Have a client side function that does partial refresh on a hidden (by CSS) xp:text/etc. that shows the current user name. Fetch the content using theNodeReferenceVariable.innerHTML. If Anonymous is the current user:

document.location.href = document.location.href

You could also do document.location.reload(), but that might result in submits being resent.

Use the XPages Extension Library REST services. Same as above, if Anonymous, reload page.