I have an unwritten rule that if I learn something and I think I’ll hit the same problem again, I try to blog about it; if I hit it again and I can’t find it on my blog, I definitely blog about it.

Yesterday I encountered the latter, so today I’m blogging about it.

As I’ve moved through understanding the languages in XPages, I use Expression Language more and more. But consider the following example:

<xp:button value="Label" id="button1">
<xp:eventHandler event="onclick" submit="false">

It seems a more efficient manner of adding an alert with the current database file path – shorter to type and better performant. Except it throws an error when it hits the browser. The stack trace is as follows, triggering the error from the createView method which runs before the XPages beforePageLoad event:

javax.faces.el.ReferenceSyntaxException: alert('#{database.filePath}');

Add SSJS as well:

<xp:button value="This errors" id="button3">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[alert('#{database.filePath} and #{javascript:database.getFilePath()}');]]></xp:this.script>

and you get a different stack trace and error, as its being processed during the Render Response phase:

javax.faces.el.MethodNotFoundException: filePath: com.ibm.domino.xsp.module.nsf.NSFComponentModule$XPagesDatabase.filePath()

It seems you can’t use Expression Language in a CSJS eventHandler. It’s fine in an Output Script control or the onComplete of an eventHandler, but not in the script property of an eventHandler.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top