【问题标题】:setting database for xp:dominoDocument via properties file通过属性文件为 xp:dominoDocument 设置数据库
【发布时间】:2015-12-15 05:51:56
【问题描述】:

我想通过 SSJS 和属性文件为 xp:dominoDocument 数据属性设置数据库位置:

<xp:this.data>
        <xp:dominoDocument var="document1" action="openDocument"
            formName="album   -   $f-album" computeWithForm="both"
            concurrencyMode="force"
            databaseName="#{javascript:datasource.getString('DB_FILEPATH')}">
            <xp:this.documentId><![CDATA[#{javascript:context.getUrlParameter("UNID")}]]></xp:this.documentId>
        </xp:dominoDocument>
    </xp:this.data>

数据源属性包含例如

DB_FILEPATH=Bildr6Phase10Data.nsf

并且可以通过

获得
<xp:this.resources>
        <xp:bundle src="/datasource.properties" var="datasource"></xp:bundle>
    </xp:this.resources>

上面的代码会抛出错误:

com.ibm.xsp.exception.EvaluationExceptionEx: Error while executing JavaScript computed expression
Error while executing JavaScript computed expression
Script interpreter error, line=1, col=12: [ReferenceError] 'datasource' not found

但是,如果我尝试:

<xp:text escape="true" id="computedField1"
        value="#{javascript:datasource.getString('DB_FILEPATH')}">
    </xp:text>

我从属性中获取价值。 我做错了什么?

【问题讨论】:

  • EL '${datasource.DB_FILEPATH}' 有效吗?
  • 我认为它应该是带有括号而不是括号的 datasource.getString['DB_FILEPATH'] 。也许你应该重命名你的包名,因为它不是数据库 SSJS 对象独有的。

标签: xpages xpages-ssjs


【解决方案1】:

尝试在 beforePageLoad 和 beforeRenderResponse 中记录 datasource.getString('DB_FILEPATH'),而不是计算字段。还要在databaseName 属性中注销一条消息。我希望在首次加载组件树时需要 databaseName 属性。但是,如果稍后加载资源字符串,我不会感到惊讶。

另一种方法是使用 xsp.properties 文件。有关于如何从 XPages OpenLog Logger 中的 xsp.properties 检索属性的代码。

【讨论】:

  • 我现在使用托管 bean 并调用 getFilepath 方法。通过这种方式似乎没有任何问题。不知道为什么。
猜你喜欢
  • 2013-01-07
  • 1970-01-01
  • 2022-08-15
  • 1970-01-01
  • 2020-07-07
  • 2022-12-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多