This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Jul 27, 2012, 1:36 PM
10 Posts
topic has been resolvedResolved

Returning to the previous page

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 3
 I have an XPages application that is made up of multiple databases.
 
There is an admin database that contains the communal content that all users can access, and then there are databases for each area containing the area specific content. 
 
A consistent header is provided regardless of where the user is. I.E. the user can be anywhere in the admin db and click a button to create a new document in their area db. 
 
The problem I have is that if a user has clicked from the admin db to create a new record in their area db I can't seem to take the user back to the previous page if they change their minds. 
 
There is a cancel button on my forms which is meant to return the user to the previous page, regardless of where that is in the site.
 
The basic Open Page-> previous page just seems to refresh the form. 
I've tried history.back and history.go(-1) (even tried -2 and -3) as CSJS behind the button, but that doesn't work either 
I've tried context.redirectToPrevious() 
and I've tried getting the HTTP_Referer from the request header. 
 
None of the above methods will give me the correct previous url. 
 
Does anyone know of a way I can achieve what I am trying to do? 
Jul 27, 2012, 1:53 PM
10 Posts
Re: Returning to the previous page
  In case anyone else has this issue, I have managed to solve it and here is how.
 
Firstly I was able to get the previous url using the client side javascript document.referrer. 
 
I then started to run into an issue where I could display this value in an alert box, but could not redirect to it using location.href. It turns out that because I had been switching between SSJS and CSJS in the same button trying different options (though not at the same time) I needed to set the event to No submission because it was still trying to run SSJS events, even though there were no actions specified, and this was overriding my CSJS redirect. 
Jul 29, 2012, 5:40 PM
586 Posts
Re: Returning to the previous page
 Rebecca,
 
I'm a huge fan of using multiple databases to seperate my data.  I'm not sure from your post if you are, but I don't recommend using multiple databases to house your xpages source code. If you can you should try and keep that in the same database.   
 
Just a thought. 
Aug 9, 2012, 2:48 PM
93 Posts
Re: Returning to the previous page
 I personally use navigation rules, based on sessionScope variables, and the breadcrumbs. For example:
 
previousStep = sessionScope.breadCrumbLevel - 1;
previousStep2 = sessionScope.breadCrumbLevel - 2;
previousStep3 = sessionScope.breadCrumbLevel - 3;
previousStep4 = sessionScope.breadCrumbLevel - 4;
sessionCommand = "breadCrumbLink" + previousStep.toString();
sessionCommand2 = "breadCrumbLink" + previousStep2.toString();
sessionCommand3 = "breadCrumbLink" + previousStep3.toString();
sessionCommand4 = "breadCrumbLink" + previousStep4.toString();

if (sessionScope.get(sessionCommand) != ""){
return sessionScope.get(sessionCommand)
} else if (sessionScope.get(sessionCommand2) != ""){
return sessionScope.get(sessionCommand2)
} else if (sessionScope.get(sessionCommand3) != ""){
return sessionScope.get(sessionCommand3)
} else if (sessionScope.get(sessionCommand4) != ""){
return sessionScope.get(sessionCommand4)
}
{
return "/XP_Home.xsp"

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal