1
votes

I have a View Panel in a tabbed panel that has the data > var property set to rowData. I have this view set to mimic the Single Category view by using a viewScope value.

When I open a XPage and click on the tab which the view panel exists, sometimes this error pops up (line 2 in the JavaScript Code is where the error is):


Unexpected runtime error
The runtime has encountered an unexpected error.

Error source
Page Name:/speakerReq.xsp
Control Id: viewColumn2 

Exception
Error while executing JavaScript computed expression
Script interpreter error, line=2, col=23: [ReferenceError] 'rowData' not found

JavaScript code

1: var href = facesContext.getExternalContext().getRequest().getContextPath();
**2: var docUNID = rowData.getDocument().getUniversalID();**
3: var formName = rowData.getDocument().getItemValueString("Form");
4: var formType = rowData.getColumnValue("Form")
5: 
6: if(formName == "clientProfile") {
7:  href + "/clientProfile.xsp?documentId=" + docUNID + "&action=openDocument&rtr=yes";
8: }
9: else {
10:     href + "/speakerProfile.xsp?documentId=" + docUNID + "&action=openDocument&rtr=yes";
11: }

The viewColumn2 that is referenced above is a column in the view which has this formula:

@ReplaceSubstring(Form; "clientProfile" : "clientFeed" : "speakerProfile" : "speakerFeed"; "Client Profile" : "Client Feedback" : "Speaker Profile" : "Speaker Feedback")

I am not sure how that would throw the error above --- clicking on that tab on most XPages works fine.

The documents that are being displayed in the view are nothing special. I compared two of them -- one that displays and one that throws the error and I could not find any differences that would cause this problem.

I cannot determine why sometimes the error appears and sometimes not.

Any help would be great!

3

3 Answers

2
votes

Perhaps this error occurs if the view is categorized and the code hits a category and not a document. You can use the folllowing code to make sure that the current row is not a category:

if (!rowdata.isCategory()) {
// insert your code here
}

This code of course assumes that rowData is available so this might not solve your issue.

Example code can be found in the Notes & Domino Application Development wiki: http://www-10.lotus.com/ldd/ddwiki.nsf/dx/notesxspviewentry_sample_javascript_code_for_xpages#isCategory+isDocument+isTotal

3
votes

try to use a different variable name curRowData --- and don't forget that stuff is case sensitive. Also your code is a big fat memory leak since rowData.getDocument initializes a NotesDocument that you don't recycle.

Try to use:

var result;
if (curRowData.isCategory()) {
   return "";
}
var href = facesContext.getExternalContext().getRequest().getContextPath();
try {
   var doc = curRowData.getDocument();
   if (doc != null) {
      var docUNID = doc.getUniversalID();
      var formName = doc.getItemValueString("Form");
      var formType = curRowData.getColumnValue("Form")
          if(formName == "clientProfile") {
          result = href + "/clientProfile.xsp?documentId=" + docUNID + "&action=openDocument&rtr=yes";
      } else {
        result = href + "/speakerProfile.xsp?documentId=" + docUNID + "&action=openDocument&rtr=yes";
      }  
   }
} catch (e) {
  // some error handling
}
if (doc != null) {
   doc.recyle();
}
return result;

Of course you would be better off just to add all values you need to the view. Saves you the need to create a NotesDocument object

0
votes

Please add a description of the XML declaring the control. I have myself gotten this error and it was because I computed the column in a wrong way; "Computed" vs JavaScript I think it was…