Max
Max

Reputation: 1210

document is created if documentId is empty

I have a dominoDocument on my Xpage which gets a document from a database if a parameter is set (param.docId). Unfortunately a document is created when the documentId results to empty (param.docId = ""). As Anonymous I am not allowed to create Documents. Therefore I get the yellow login screen.

<xp:dominoDocument
    var="contactData" action="openDocument">
    <xp:this.databaseName><![CDATA[#{javascript:var dbEntryConfig:DatabaseEntry=getDatabase()}]]></xp:this.databaseName>
<xp:this.documentId><![CDATA[#{javascript:var docId = param.docId;
    if(docId != null){
        contactSaveData.replaceItemValue("contactDataDocId",docId);
    }else{
        docId = contactSaveData.getItemValueString("contactDataDocId");
    }
    return docId;}]]>
</xp:this.documentId>
</xp:dominoDocument>

Is there any way to prevent creating a document?

Upvotes: 0

Views: 63

Answers (1)

Paul Stephen Withers
Paul Stephen Withers

Reputation: 15739

By default all dominoDocument datasources will pull their settings from the URL parameters. If you're setting the documentId, you need to set ignoreRequestParams="true", otherwise anything in the URL will override whatever you define there. Also, that will ensure action="openDocument" cannot be overridden by amending the URL.

Check any save button on the page as well. If it has save="true", that means "save all datasources". Without ignoreRequestParams="true", it may also be saving this datasource. The "Save Data Sources" simple action also saves all datasources on the page.

Upvotes: 1

Related Questions