Reputation: 911
Has anyone noticed an issue with datacontexts in xpages. In certain scenario a single xpage with multiple custom controls would result in the datacontext being evaluated 12 times during a single page load?? Does this happen with other dataSources as well?
Here is a simple example, which gets executed 3 times!!
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xe="http://www.ibm.com/xsp/coreex">
<xp:this.dataContexts>
<xp:dataContext var="doc1">
<xp:this.value><![CDATA[#{javascript:var doc:NotesDocument = database.createDocument();
doc.replaceItemValue("Form", "frmContact");
doc.replaceItemValue("fldFirstName", "test");
print("got here");
return doc;}]]></xp:this.value>
</xp:dataContext>
</xp:this.dataContexts>
<xp:inputText id="inputText1" value="#{doc1.fldFirstName}"></xp:inputText>
</xp:view>
Should I not be using dataContexts in my application?
Upvotes: 0
Views: 481
Reputation: 1111
And also watch out, if you are using partial refresh. Let's assume, you datacontext is in id B and you do a refresh on id A. The datacontext in id B will also be refreshed. Also happens to all other data sources.
I have described this behaviour here http://www-10.lotus.com/ldd/xpagesforum.nsf/topicThread.xsp?action=openDocument&documentId=56E9B8537DA50A90852579A6002EAC64#FA00DE3675A456C0852579AB005A1FF4
And there are also some hints about a PMR and a possible workaround for this.
Upvotes: 1
Reputation: 8086
As with all other value bindings, if you change the # to a $, the value attribute of the dataContext may be requested multiple times, but the calculation to determine that value will only be executed once.
Upvotes: 1
Reputation: 2635
Just like other controls on the page, the datacontext could be evaluated multiple times. See here for more information about the benefits of dataContexts. But in my opinion, from your code example, it could be faster to use a xp:data source but I'm not sure.
Upvotes: 1