XPage按钮在4次ajax调用后无响应

时间:2015-10-21 12:17:21

标签: xpages

也许我会发疯,但我认为这是XPages的问题

我正在使用XPage和Domino 9.0.1 FP3。 似乎当我做一个XPage 4 ajax调用xagent的页面时,一个接一个地页面上的所有按钮都没有响应。 最多3个ajax调用一切正常... doopo第四个按钮变得无法响应。 眼见为实!!!! **

-------------------------------------------------------------------------------
****This is my example page**:** testPage.xsp
-----------------------------------------------------------------------------

<? Xml version = "1.0" encoding = "UTF-8"?>
<Xp: view xmlns: xp = "http://www.ibm.com/xsp/core">

<Xp: button value = "Update edit box" id = "button1">
<Xp: EventHandler event = "onclick" submit = "false"
refreshMode = "partial" refreshId = "inputText1">
<xp:this.action><![CDATA[#{javascript:getComponent("inputText1").setValue(session.createDateTime(@Now()))}]]></xp:this.action>
</ Xp: EventHandler> </ xp: button>
<Xp: inputText id = "inputText1"> </ xp: inputText>

<Xp: br> </ xp: br> <xp: button value = "Call for Ajax 3 time (button Work)" id = "button3">
<Xp: EventHandler event = "onclick" submit = "false">
<Xp: this.script> <! [CDATA [for (i = 0; i <3; i ++) {
   dojo.xhr.get ({
  url: "http://app.quattroemme.it/home.nsf/testXagent.xsp"
  handleAs: "xml"
  load: function (data) {
  }
});

}]]> </ Xp: this.script>
</ Xp: EventHandler> </ xp: button>
<Xp: br> </ xp: br>
<Xp: br> </ xp: br>
<Xp: button value = "Call for Ajax 4 time (button unresponsive)" id = "button2">
<Xp: EventHandler event = "onclick" submit = "false">
<Xp: this.script> <! [CDATA [for (i = 0; i <4; i ++) {

   dojo.xhr.get ({
  url: "http://app.quattroemme.it/home.nsf/testXagent.xsp"
  handleAs: "xml"
  load: function (data) {
  }
});

}]]> </ Xp: this.script>
</ Xp: EventHandler> </ xp: button>
</ Xp: view>


--------------------------------------------------------------------------------
This is the simple xagent I call with ajax  (testXagent.xsp)
--------------------------------------------------------------------------------

// The external context gives access to the servlet environment
var exCon = facesContext.getExternalContext(); 

// The writer is the closest you get to a PRINT statement
// If you need to output binary data, use the stream instead
var writer = facesContext.getResponseWriter();

// The servlet's response, check the J2EE documentation what you can do
var response = exCon.getResponse();

// In this example we want to deliver xml and make sure it doesn't get cached
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");

// Here all your output will be written
writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<christmas date\"24Dec\" />");

// We tell the writer we are through
writer.endDocument();
print ("XAGENT")
facesContext.responseComplete();

2 个答案:

答案 0 :(得分:1)

确保您的XAgent的XPage未设置为存储状态。这是通过转到“属性”面板的“所有属性”选项卡完成的,并在“基本”部分中将viewState设置为 nostate 。否则,XPage的组件树存储在服务器端。可以存储固定数量的组件树,您可以通过加载多个窗口选项卡或重复加载未覆盖viewState的XAgent来实现。结果是XPage对部分刷新无响应。 (不可否认,我总是使用部分刷新来调用XAgent,所以我不能100%确定这也会影响dojo.xhr.get。)

保持服务器端存储组件树是XPage中的正常行为,并且要求XPage为“有状态”。否则,寻呼机上的“下一个”按钮只会转到第2页,因为它不知道浏览器当前所在的页面,只知道默认页面是什么,即第1页。

答案 1 :(得分:0)

谢谢保罗。我使用viewState = nostate解决了我的问题。

我的问题出现在使用ExtJs TreeGrid按需打开节点 TreeGrid使用两个xagent从服务器读取数据并返回ExtJ用于渲染树的json。当我不得不打开所有树时,TreeGrid会自动为每个节点调用xagent并且按钮已经变得无法响应.... !!!!!!!现在一切都好了