Patrick Kwinten
Patrick Kwinten

Reputation: 2048

Xpages - compute properties for dominoDocument does not work as expected

on an XPage I have defined a dominoDocument datasource as followed:

<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
    xmlns:xc="http://www.ibm.com/xsp/custom">
    <xp:this.resources>
        <xp:bundle src="/datasources.properties" var="datasources" />
        <xp:bundle src="/environment.properties" var="env"></xp:bundle>
    </xp:this.resources>
    <xp:this.data>
        <xp:dominoDocument formName="fa_Attachment" var="attachDoc">
            <xp:this.databaseName><![CDATA[#{javascript:return env["srv_notesname"] + "!!" + utilityBean.getFilePath() + "//" + datasources["db_inbox_filepath"]}]]></xp:this.databaseName>
        </xp:dominoDocument>
    </xp:this.data>

in environment.properties i have listed key/value pair:

# ENVIRONMENT SETTINGS REFERENCES
#
srv_notesname=Server01/Server/ACME

similar for datasource.properties:

# DB Inbox
db_inbox_filepath=inbox.nsf

when I load the XPage I get the message:

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

I would have expect that I could make the data binding a bit dynamic, so what am I doing wrong?

Upvotes: 0

Views: 87

Answers (1)

Paul Stephen Withers
Paul Stephen Withers

Reputation: 15739

Datasources that are children of the xp:view element need to have their properties generated before beforePageLoad. "Print" statements will allow you to confirm that, as I did for my session a few years ago "Marty, You're Just Not Thinking Fourth Dimensionally" (probably still available as a webinar on the TLCC website).

Making it a child of a Panel will allow you to pick up things set in beforePageLoad.

Datasources can't be changed during the life of a page unless scoped to request. So you can use ${javascript:...} instead of #{javascript:...}

Upvotes: 1

Related Questions