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



Mar 17, 2011, 6:15 AM
38 Posts

Error handling in XPage

  • Category: Debugging
  • Platform: Windows
  • Release: 8.5.1
  • Role: Developer
  • Tags: xpages,error handling
  • Replies: 4
I have an XPage "ErrorThrowingPage.xsp" which has a computed field in which following SSJS code is written:
 
try {
 var myView:NotesView = database.getView("NO_SUCH_VIEW");
 var doc:NotesDocument = myView.getFirstDocument(); // This line throws error
} catch ( e ) {
 print(e.toString());
 sessionScope.put("ERROR_OBJECT", e.toString());
 requestScope.put("ERROR_OBJECT", e.toString());
 context.redirectToPage("CustomErrorPage.xsp", true);
 
On the line "var doc:NotesDocument = myView.getFirstDocument();" error is thrown as no view is found. It goes into catch block where I print the error, put the error in session & request scope variables and redirect the page to another XPage "CustomErrorPage.xsp".
 
In "CustomErrorPage.xsp" I have another computed field with following SSJS code:
 
sessionScope.get("ERROR_OBJECT") + "\n" + requestScope.get("ERROR_OBJECT") 
 
The problem is that sessionScope gets me the error but requestScope returns null. I DON'T want to use sessionScope but requestScope simply doesn't seem to work!!
 
Any ideas!!?? 
 
Regards, 
Naveen Maurya 
Mar 17, 2011, 11:38 AM
22 Posts
Re: Error handling in XPage
"Objects in the requestScope map last for the duration of a single request." - Quote taken straight out of the "Mastering XPages" book.
 
Essentially, by the time you have redirected the user to your custom error page, I'd say that the requestScope variables from your original request have been cleared.
 
Why do you want to avoid using a sessionScope variable?
Mar 18, 2011, 12:23 PM
38 Posts
Re: Error handling in XPage
If I put someting in requestScope then it should persist in the for atleast one request i.e. from "ErrorThrowingPage.xsp" TO "CustomErrorPage.xsp". So it should persist for that one request. Got this from XPages tutorial: http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Tutorial-Introduction-to-XPages-Exercise-9. Am I right on this one?
 
The reason I want to aviod putting error in sessionScope is that it will  persist for entire user's session which is not required and what if another error occurs in the same session.
 
Mar 18, 2011, 12:34 PM
22 Posts
Re: Error handling in XPage
 Not sure Naveen, but it seems that the requestScope is acting less persistent then you require.
Surely you can just clear the sessionScope variable once it has been displayed? 
Mar 18, 2011, 12:34 PM
22 Posts
Re: Error handling in XPage
 Not sure Naveen, but it seems that the requestScope is acting less persistent then you require.
Surely you can just clear the sessionScope variable once it has been displayed? 

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