【发布时间】:2017-05-23 05:07:50
【问题描述】:
我正在关注article,它告诉我们如何存储全局参数,以及配置文件如何为经典的 Notes 应用程序工作。我按照文章的步骤并根据必要的全局参数实现了类,但是当我调用 javascript 对象的方法时,会发生以下错误。我有点困惑,因为在应用程序的其他地方调用相同的方法可以正常工作。下面是 javascript 对象的代码,作为文章中的示例实现。
脚本解释器错误,line=12,col=21:[TypeError] 在“java.util.HashMap [Dynamic Java Wrapper, java.util.HashMap]”类型的对象上调用方法“getDbRH()”时出错
var dbFotoConfig = {
getDbFoto : function ( ) {
var cache = this. getCacheObject ( ) ;
var result = cache.get( "DbFoto" ) ;
if (result == null ) {
// Here is where you would do @DBSomething or worse
var visao:NotesView=database.getView("Configuracoes")
var doc:NotesDocument=visao.getFirstDocument();
if (doc!=null)
{
result= [doc.getItemValueString("servidor_foto"),doc.getItemValueString("base_foto"),doc.getItemValueString("visao_foto")]
cache.put("DbFoto",result)
sessionScope.put ( "dbFotoConfig" ,cache )
}
else
{
cache.put("DbFoto",null)
sessionScope.put ( "dbFotoConfig" ,null )
}
}
return result ;
} ,
/* Here would be much more of these functions */
/* Utility functions for cache management */
/* Retrieves the configuration object from a cache store.
There are many ways to do that */
getCacheObject : function ( ) {
// Consider carefully where to cache. Typical places
// are sessions or applications
var curCache = sessionScope. get ( "dbFotoConfig" ) ;
if (curCache == null ) {
curCache = new java. util. HashMap ( ) ;
sessionScope. put ( "dbFotoConfig" ,curCache ) ;
}
return curCache ;
} ,
/* Resets the cache */
reset : function ( ) {
var curCache = new java. util. HashMap ( ) ;
sessionScope. put ( "dbFotoConfig" ,curCache ) ;
}
}
var dbRHConfig = {
getDbRH : function ( ) {
var cache = this. getCacheObject ( ) ;
var result = cache. get ( "DbRH" ) ;
if (result == null ) {
// Here is where you would do @DBSomething or worse
var visao:NotesView=database.getView("Configuracoes")
var doc:NotesDocument=visao.getFirstDocument();
if (doc!=null)
{
result=[doc.getItemValueString("servidor_RH"),doc.getItemValueString("base_RH"),doc.getItemValueString("visao_RH")]
cache.put("DbRH",result)
sessionScope.put ( "dbRHConfig" ,cache )
}
else
{
cache.put("DbRH",null)
sessionScope.put ( "dbRHConfig" ,null )
}
}
return result ;
} ,
/* Here would be much more of these functions */
/* Utility functions for cache management */
/* Retrieves the configuration object from a cache store.
There are many ways to do that */
getCacheObject : function ( ) {
// Consider carefully where to cache. Typical places
// are sessions or applications
var curCache = sessionScope. get ( "dbRHConfig" ) ;
if (curCache == null ) {
curCache = new java. util. HashMap ( ) ;
sessionScope. put ( "dbRHConfig" ,curCache ) ;
}
return curCache ;
} ,
/* Resets the cache */
reset : function ( ) {
var curCache = new java. util. HashMap ( ) ;
sessionScope. put ( "dbRHConfig" ,curCache ) ;
}
}
【问题讨论】:
标签: javascript xpages profile