我没有对这个数据库进行任何更改,突然间,我在加载各种Xpages时出现(500)错误.在这个,当我在数据库属性的xpages选项卡上切换到"显示Xpage运行时错误"时,它会在web下面显示错误.
如果我删除了包含此客户端代码的按钮(它之前已经完美地验证了编辑框),则错误只会移动到页面上的下一段JavaScript并产生类似的错误.
我试过"清理"项目.我试图用服务器ID签署整个数据库.
任何帮助将非常感激!
The runtime has encountered an unexpected error.
Error source
Page Name:/msr.xsp
Control Id: _id20
Exception
Error while executing JavaScript computed expression
Script interpreter error, line=3, col=8: [ReferenceError] 'XSP' not found
Run Code Online (Sandbox Code Playgroud)
------按钮控件:
<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action>
<xp:actionGroup>
<xp:actionGroup>
<xp:modifyField
name="Status">
<xp:this.value><![CDATA[#{javascript:if (document1.isNewNote()) {
"Submitted to Project Officer";
}
else if (document1.Status == "Submitted to Project Officer"){
"Submitted to Supervisor";
}
else{
"Completed";
}}]]></xp:this.value>
</xp:modifyField>
<xp:saveDocument
var="document1">
</xp:saveDocument>
<xp:changeDocumentMode
mode="readOnly" var="document1">
</xp:changeDocumentMode>
</xp:actionGroup>
</xp:actionGroup>
</xp:this.action>
<xp:this.script>
<xp:executeClientScript>
<xp:this.script><![CDATA[#{javascript:
if(XSP.getElementById("#{id:ProjectTitle}").value == ""){
XSP.getElementById("#{id:ProjectTitle}").focus();
XSP.getElementById("#{id:ProjectTitle}").style.backgroundColor = "pink";
alert("Please enter a Project Title.");
return false;
}
else{
XSP.getElementById("#{id:ProjectTitle}").style.backgroundColor = "#ffe";
}
///NOT sole source
if(XSP.getElementById("#{id:RT}").innerHTML == "MSR"){
if(XSP.getElementById("#{id:SoleSource}").checked == false){
if(XSP.getElementById("#{id:SS_Name1}").value == ""){
XSP.getElementById("#{id:SS_Name1}").focus();
XSP.getElementById("#{id:SS_Name1}").style.backgroundColor = "pink";
alert("Please fill in the Name of Suggested Source 1.");
return false;
}
else{
XSP.getElementById("#{id:SS_Name1}").style.backgroundColor = "#ffe";
}
}
}
}]]></xp:this.script>
</xp:executeClientScript>
</xp:this.script></xp:eventHandler>
</xp:button>
Run Code Online (Sandbox Code Playgroud)
script您的executeClientScript操作的属性看起来像是在计算.源应该看起来像这样:
<xp:executeClientScript>
<xp:this.script>
<![CDATA[if(XSP.getElementById("#{id:ProjectTitle}").value == ""){...
]]></xp:this.script>
</xp:executeClientScript>
Run Code Online (Sandbox Code Playgroud)
相反,你有这个:
<xp:executeClientScript>
<xp:this.script>
<![CDATA[#{javascript:if(XSP.getElementById("#{id:ProjectTitle}").value == ""){...
}]]></xp:this.script>
</xp:executeClientScript>
Run Code Online (Sandbox Code Playgroud)
该语法意味着,您不是简单地输入客户端JavaScript来执行,而是运行服务器端JavaScript来计算客户端JavaScript应该是什么.服务器端JavaScript没有XSP像客户端JavaScript那样定义全局对象,这就是为什么你会得到一个ReferenceError.
#{javascript:从CDATA块的开头删除,最后}从结尾删除,代码将在您想要的上下文中执行.