XPages sessionScope vs. JSF sessionScope?

Are the sessionScope vars I set on my XPage in server-side Javascript available to my java classes? If so, what part of the JSF api are they exposed in? Maybe I am using the wrong one…

For example, on button click, I have the following code in my server-side javascript behind the button:

sessionScope.FOKeySelected = FORowData.id;

This button click currently runs a Full Update on the page so my repeat control refreshs… My repeat control in turn runs my java code that populates some java beans. In that code, I need the sessionScope var “FOKeySelected”. But FONbr does not get populated by this sessionScope var using the following code:

FONbr = sessionGetter().getRequestMap().get(“FOKeySelected”);

public static ExternalContext sessionGetter(){

	FacesContext context = FacesContext.getCurrentInstance( ); 

    ExternalContext extContext = context.getExternalContext( );

	return extContext;		

}

I have verified that my “sessionGetter” works by setting and getting a JSF sessionScope in two separate java calls. Matter-of-fact, my workaround involves pulling data off of a field in the XPage UI and putting it in my JSF sessionScope var… then retrieving this info later on subsequent runs.

I know I am leaving out a bunch of detail (trying to keep my example simple!)… so hopefully this makes sense! But, back to my basic question at hand… can I get a hold of the XPage sessionScope vars within my java code in the same db?

Thanks!!

Subject: sessionScope is JSF sessionMap

Yes, the XPages sessionScope is the same as the JSF sessionScope.

It is available through these JSF APIs:

FacesContext facesContext = FacesContext.getCurrentInstance();

Map<String,Object> sessionScope =facesContext.getExternalContext().getSessionMap();

Your example was calling ExternalContext.getRequestMap() which is the requestScope.

You can also resolve any of the global variables using the JSF VariableResolver to look up the variable name:

FacesContext facesContext = FacesContext.getCurrentInstance();

Map<String,Object> sessionScope = (Map<String,Object>)

facesContext.getApplication().getVariableResolver().resolveVariable(facesContext,

"sessionScope");

Subject: I have to add something…

I said I had a “workaround” I could use by setting and getting my sessionScope var all in java. Well, it works, but not on every type of page refresh. For example, if I am using a pager control and try to move to my next page of FOs… it thinks my sessionScope var is not set.

I am back to square one!