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



Feb 4, 2013, 10:02 AM
11 Posts

Can I access sessionScope variables in JAVA agent ?

  • Category: Other
  • Platform: Windows
  • Release: 8.5.3
  • Role:
  • Tags: JavaAgent scope variable
  • Replies: 7
Hi,
 
I have an application where in afterPageLoad a Java agent is called to generate XML.
I'd like to pass some info to the agent. 
 
Can I address sessionScope variables in the java agent ? 
Or is there another way ?
 
This is how the xagent is called :

var   parsedxml = xmldocument.parse(http://localhost/appl/timex.nsf/javasqldata.xml);

javasqldata.xml is the alias for the java agent.
  
It's my first java agent so ... 
 
Thanks ! 
Feb 4, 2013, 6:30 PM
366 Posts
Re: Can I access sessionScope variables in JAVA agent ?
 There is no shared memory between the XPages JVM and the Agent JVM.
 
 
You could however use the run agent with document context introduced in 8.5.3 to pass variables into the agent.  
 
You don't have to save the document.  
 
So store the values to fields in a document pass that document as the context document to the agent and read the values from the fields in the agent. 
 
 
Feb 5, 2013, 11:53 AM
11 Posts
Re: Can I access sessionScope variables in JAVA agent ?
Paul, Thank you for the reply.  Didn't know that was possible.
But it won't help me out ...
If I want to make use of the document context, I need to set the security of the agent to 'run as webuser'.
In that case, the XML parser gives an error. 
 
So the main problem is, if the agent is run in name of the signer (so not the web user), I need to access some 'user' settings.  In a document would be fine, in a profile, in a variable, ... 
Feb 5, 2013, 1:40 PM
366 Posts
Re: Can I access sessionScope variables in JAVA agent ?
 So replace the agent with an XAgent (XPage with no UI, has it's render property set to false).
 
This will allow you to call java code elements to do the heavy java stuff, but still use Scoped Variables. 
 
If you are not familiar with XAgents, just google it or let me know and I will send you the base code. 
Feb 6, 2013, 1:04 PM
11 Posts
Re: Can I access sessionScope variables in JAVA agent ?
Paul, thanks again for your reply.
I used to have a javascript XAgent that generated the correct XML but the parser always gave an error.  The same error I had when the JAVA agent executes as web user.
So if I can access my 'context' I cannot get the xml parser to do its job, if I cannot access 'context' the parser works but I have no valid data ... 
 
This is the error. Even with /xml the same error is generated. The .xml itself look identical to the one generated by the JAVA agent.
Page Name: /grid_repeat.xsp
Script interpreter error, line=8, col=29: Error calling method 'parse(string)' on java class 'org.apache.xerces.jaxp.DocumentBuilderImpl'
     6: //Read the XML from the Domino Agent
     7: //var parsedxml = xmldocument.parse("http://localhost/appl/timex.nsf/javasqldata.xml");
->   8: var parsedxml = xmldocument.parse("http://localhost/appl/timex.nsf/inputxml.xsp");
 
Thanks for your help ! As single-developer-in-the-house it's not easy to find solutions from time to time ... 
 
Regards, 
An 
Feb 6, 2013, 3:13 PM
366 Posts
Re: Can I access sessionScope variables in JAVA agent ?
 Have you tried using the relative URL instead of the complete URL ??
 
Try using just the database name and XAgent name.   
 
If you can't get that working I will dig up my code example on this.   
Feb 7, 2013, 8:51 AM
16 Posts
Re: Can I access sessionScope variables in JAVA agent ?
 Sounds as if you may need to get a session as signer to run parts of your code in an XAgent. You can do that for just some of the code (say in a function) in your XPage.
 
/John 
Feb 7, 2013, 10:56 AM
11 Posts
Re: Can I access sessionScope variables in JAVA agent ?
After more than a week ... close to be very desperate!!!
 
If I select the java agent to run as web user, and 'call' the xagent like this :

var parsedxml = xmldocument.parse(http://localhost/appl/timex.nsf/mssqltoxml.xml);

 The agent thinks I am anonymous. (agentContext.getEffectiveUserName() ).
 
If I open the xml myself : http://xpagestest/appl/timex.nsf/mssqltoxml.xml the xml file looks great.
 
If I select the agent to run as signer,  

var parsedxml = xmldocument.parse(http://localhost/appl/timex.nsf/mssqltoxml.xml);

works as expected ... 
 
But ... I need the java agent for generating the xml based on information that is different per user.
If the agent only recognises the signer, not the webuser, I don't see a way to generate xml with the user info ...
 
The samples I have found on the internet do a lookup in a database (names.nsf), based on anonymous access so that won't help me ...
 
Can I call an XAgent (the one that looks for user data) and return that info to the java agent ? What is the syntax for calling the XAgent ? With getAgent I cannot get it to work. 
 
Thanks so much for trying to help me. 

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