Hi,
this is quite a strange one: just tried to implement a script block in an XPage to then be able to use XSP.addOnLoad to execute some function onLoad. But it doesn’t work, all I get is an “Unexpected runtime error” telling me that XSP was not a vlid object.
So I built a fresh XPage ina different database and included nothing but that script block, to be sure that I hadn’t run into some different problem. But no: same thing here.
Here’s the raw XML for my test page:
<?xml version="1.0" encoding="UTF-8"?><xp:view xmlns:xp=“http://www.ibm.com/xsp/core”>
<xp:scriptBlock id="scriptBlock1">
<xp:this.value><![CDATA[#{javascript:XSP.addOnLoad(
function() {
alert("it's me!");
}
)}]]></xp:this.value>
</xp:scriptBlock>
</xp:view>
And here’s the debugging message:
Unexpected runtime error
The runtime has encountered an unexpected error.
Error source
Page Name:/testAddOnLoad.xsp
Control Id: scriptBlock1
Property: value
Exception
Error while executing JavaScript computed expression
Script interpreter error, line=1, col=5: Error calling method ‘addOnLoad(function)’: ‘XSP’ is not a valid object
Javascript code
1: XSP.addOnLoad(
2: function() {
3: alert(“it’s me!”);
4: }
5: )
► ▼ Stack Trace
Don’t have a clue what’s wrong here, as I remember having used XSP.addOnLoad successfully in the past…