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



May 29, 2014, 12:12 PM
5 Posts

Why this SSJS is not working

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 3

I am trying to populate array in 'Before Render Response' page event storing data in requestScope/viewScope and use the data as source for repeat. However, I can't get scope variable to store any data:

beforeRenderResponse code is:
    doTest();

SSJS that is included in the page is:

function doTest(){
 var q=new Array();
 loadStructure(q);
 requestScope.x=q; // tried also requestScope.put('x',q) with the same result
 var y=requestScope.x;
 println('z='+q['A1']);
 println('q='+requestScope.x['A1']);
 println('s='+y['A1']);
 println('w='+requestScope.x);

 requestScope.x['A1']='AAAAAAAAAAAAAAAAAAAA';
 println('p='+requestScope.x['A1']);
}

function loadStructure(r){    
    r['A1']='aaaaaaaaaaaaaaaaaaaaaaaaaaa';    
    return r;    
}

Console reads:

[15EC:0203-14B8] 05/29/2014 08:08:56 AM  HTTP JVM: z=aaaaaaaaaaaaaaaaaaaaaaaaaaa   <-- output as expected
[15EC:0203-14B8] 05/29/2014 08:08:56 AM  HTTP JVM: q=undefined    <-- did not store value
[15EC:0203-14B8] 05/29/2014 08:08:56 AM  HTTP JVM: s=undefined   <-- nothing retrieved
[15EC:0203-14B8] 05/29/2014 08:08:56 AM  HTTP JVM: w=[] <-- value exists as empty array
[15EC:0203-14B8] 05/29/2014 08:08:56 AM  HTTP JVM: com.ibm.xsp.exception.EvaluationExceptionEx: Error while executing JavaScript action expression

Does not matter if I use viewScope or requestScope, or put and get methods in the same to access stored value

 

What am I doing wrong?

Domino 8.5.3FP6/ Win2008 32 bit

 

 

May 29, 2014, 12:48 PM
366 Posts
Not Valid in beforeRenderResponse

I don't believe that either on of those scopes are valid when set in beforeRenderResponse.

What happens when you try using a session scope variable?

Why does it need to be in the beforeRenderResponse event?

May 29, 2014, 3:06 PM
5 Posts
yes, they are valid

requestScope and viewScope are valid everywhere.

I narrowed it down to if I associate array of basic types (e.g. string) it would work, but it won't accept array of custom object.

So I am putting a custom object  that contains memeber array , and that seems to be working.

Strange

Jul 10, 2014, 7:26 PM
170 Posts
Change to this

Change

 loadStructure(q);

to

q= loadStructure(q);

that should fix your code

 

/Fredrik

Http://www.xpagedeveloper.com 


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