If you are developing Java code in the Java perspective of Domino Designer in Eclipse and need to access global Javascript variables like the current Notes Session, here is a snippet how to do that:
/
* Returns the current Notes session instance of the Javascript engine
*
* @return Session
*/
public static Session getCurrentSession() {
FacesContext context = FacesContext.getCurrentInstance();
return (Session) context.getApplication().getVariableResolver().resolveVariable(context, "session");
}
There is also a helper class "com.ibm.xsp.model.domino.DominoUtils" in the XPages runtime with methods like getCurrentSession() and getCurrentDatabase() as an alternative way.
Please keep in mind that the NotesSession is recreated on every XPage access. So storing the session object and any derived Notes objects like views and documents in your own code and reusing it will most probably result in an exception "Object has been removed or recycled".
Always grab the current session from the JavaScript engine.