Reputation: 1343
After my users complete a form, I want them to return to the page that they were on before completing / editing the form. How can I save the current page in scope variable in xPages?
Upvotes: 0
Views: 1476
Reputation: 366
Add the below code in the afterpageLoad event of the view:
sessionScope.put('webFrom',context.getUrl().getSiteRelativeAddress(context))
Add the below code to the onClick event of the link/button, which redirects the user:
var redirectToPage = sessionScope.get('webFrom')||'';
redirectToPage != ''? context.redirectToPage(redirectToPage):context.redirectToHome()
Upvotes: 1
Reputation: 378
Get the current location using: (xpagescheatsheet.com) Full Path Including page name facesContext.getExternalContext().getRequest().getRequestURI(), store that in a sessionScope variable, then use that value to redirect user as needed.
Upvotes: 3
Reputation: 8465
Have you tried using the inbuilt previous page function?
select the button, go to events tab and create an onclick event, in the drop down choose openPage event. Inside there is an option of "previousPage" as the page to move to.
failing that if you have some custom use case, why not have a scope populate in the "beforePageLoad" event on an XPage and either hard code it or if in a custom control figure it out from the URL. you will have to leave it out of the form page or else run script everywhere there is a link / button moving to another page
Upvotes: 2