2015-12-14 45 views
0

我想設置爲XP一個數據庫的位置:通過SSJS dominoDocument數據屬性和屬性文件:設置數據庫: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> 

我得到的價值財產。 我在做什麼錯?

+0

確實EL'$ {datasource.DB_FILEPATH}'工作嗎? –

+0

我認爲它應該是datasource.getString ['DB_FILEPATH']括號,而不是paranthesis。也許你應該重命名你的包名,因爲它不是數據庫SSJS對象的唯一。 –

回答

1

取而代之的是計算字段的,嘗試在beforePageLoad和beforeRenderResponse記錄datasource.getString('DB_FILEPATH')。同時註銷databaseName屬性中的消息。我期望第一次加載組件樹時需要databaseName屬性。但是,如果稍後加載資源字符串,我不會感到驚訝。

另一種可能是使用xsp.properties文件。有關於如何從XPages OpenLog Logger中的xsp.properties中檢索屬性的代碼。

+0

我現在使用託管bean並調用getFilepath方法。通過這種方式似乎沒有任何問題。不知道爲什麼。 –