问题
I have a XPage ("xBase") containing multiple IFrames, each showing a XPage ("xIFrame") in my database. When clicking on a button in xBase, a sessionScope variable is set and a label showing this variable is partially refreshed (see example code). Displaying the variable this way works fine as long as there are not too many IFrames. In the short demo example below the display only works up to 3 IFrames, but as soon as there are 4 or more present, the sessionScope variable is not set anymore.
I tested the given example in Notes Client 8.5.3, Firefox 13.0.1 and Safari 5.1.7 - with the same result. It does not appear to be a problem with the partial refresh itself because refreshing a label showing the current time works properly. Can anybody please tell me what the problem is?
XPage "xBase":
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xc="http://www.ibm.com/xsp/custom">
<xp:this.beforePageLoad><![CDATA[#{javascript:sessionScope.remove("testvar");}]]></xp:this.beforePageLoad>
<xp:div id="divIFrames">
<iframe src="xIFrame.xsp?para0=abc" id="iframe0" name="iframe0"></iframe>
<iframe src="xIFrame.xsp?para0=def" id="iframe1" name="iframe1"></iframe>
<iframe src="xIFrame.xsp?para0=ghi" id="iframe2" name="iframe2"></iframe>
<iframe src="xIFrame.xsp?para0=jkl" id="iframe3" name="iframe3"></iframe>
<iframe src="xIFrame.xsp?para0=mno" id="iframe4" name="iframe4"></iframe>
</xp:div>
<xp:br/>
<xp:button value="refresh iframes" id="button0">
<xp:eventHandler event="onclick" submit="true" refreshMode="partial" refreshId="divIFrames"></xp:eventHandler>
</xp:button>
<xp:br/><xp:br/>
<xp:label id="label"><xp:this.value><![CDATA[#{javascript:new Date().toUTCString()+": "+sessionScope.containsKey("testvar")}]]></xp:this.value></xp:label>
<xp:br></xp:br>
<xp:button value="set sessionScope / refresh label" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="label">
<xp:this.action><![CDATA[#{javascript:sessionScope.put("testvar","STRING");}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
</xp:view>
XPage "xIFrame" (just a label showing time and url > simple to ensure it is not causing the problem):
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:label value="#{javascript:new Date().toUTCString()+':'+context.getUrl().toString()}"></xp:label>
</xp:view>
回答1:
The problem can be solved by adding
xsp.persistence.tree.maxviews=16
to your database's xsp.properties file and afterwards cleaning the project. The value of 16 is arbitrary, just make sure it's higher than the number of IFrames you plan to use.
All the credit is due to Sven Hasselbach and Per Henrik Lausten who provided this solution.
来源:https://stackoverflow.com/questions/16052911/cannot-set-sessionscope-variable-when-multiple-iframes-are-present-on-a-xpage