« Back to home

XPages JavaScript mystery meat

When using XPages, I try to build as much as possible in Java, and then use as little JavaScript as possible to glue the Java code into XPages.

The main problem I hit when doing this is ensuring that my Java methods have the right type signatures to get found and called by JavaScript. It’s confusing to call someMethod(true) and find that you get a run-time error saying there’s no Java method someMethod(boolean), even though there is.

So I put together a quick Java class to dump back the types of the objects it was passed, and then fed it everything I could think of from an XPage. Here’s the result.

Function arguments

Parameter Received as
boolean java.lang.Boolean
number java.lang.Double
null null
string java.lang.String
array java.util.Vector
hash com.ibm.jscript.std.ObjectObject

Predefined variables

Parameter Received as
applicationScope com.sun.faces.context.ApplicationMap
cookie com.sun.faces.context.RequestCookieMap
facesContext com.ibm.xsp.domino.context.DominoFacesContext
header com.sun.faces.context.RequestHeaderMap
headerValues com.sun.faces.context.RequestHeaderValuesMap
initParam com.sun.faces.context.InitParameterMap
param com.sun.faces.context.RequestParameterMap
paramValues com.sun.faces.context.RequestParameterValuesMap
requestScope com.sun.faces.context.RequestMap
sessionScope com.sun.faces.context.SessionMap
view com.ibm.xsp.component.UIViewRootEx2
document data source com.ibm.xsp.model.domino.wrapped.DominoDocument
view data source lotus.domino.local.View
extlib object data source The Java class of your object data source
predefined variable ‘database’ com.ibm.domino.xsp.module.nsf.NSFComponentModule.XPagesDatabase
predefined variable ‘session’ lotus.domino.local.Session
text field control via getComponent com.ibm.xsp.component.xp.XspOutputText or other appropriate class from that package

Note that many of the JSF and XPages variables are accessible directly from Java, so you generally shouldn’t need to pass them as parameters — but I’ll leave that decision to you.