It seems that more than four assynchrounous POST requests from non-dojo javascript control to another xpage destroy the view state for the current page so that the button serverside script no longer works. This is despite the fact that the main page is not modified by this POST request. Am I doing something wrong or is it how xpages are designed to work?
More details:
I have got an xpage (lets call it page1.xsp) that on one side has got few fields and a "renderResults" button and on the other side it displays the results. The fields are bound to request scope variables, the button uses server side onclick event and it sets a request scope variable called renderResults to true and when clicked it should display the result of operations with the input parameters.
When first loaded the results side is empty and it is only rendered when the renderResults is set true, ie. when the button is clicked. The side that displays results uses a non-dojo javascript control. The control displays the results fine and works OK. Now this javascript control is able to post the selection of rows to the server as http POST request, i.e. it contains a button ("saveSelection") which upon pressing makes and ajax POST request to another page -page2.xsp - and retrieves results. The user's web browser view does not change. Nothing happens to the main page on retrieving the results.
This request is a simple POST request that is not controlled by Xpages at all, it is fully initiated by the non-dojo javascript control. The xpage page2.xsp, which intercepts the POST request, has got its render property set to false, and it outputs customary xml during its afterrenderresponse event, basically confirming that it received the request. This works fine.
However, when I try to input another set of parameters and press the "renderResults" button to display new results, many times the serverside onclick event of the button no longer runs. (verified by print statement).
I know that it is not a problem with the non-dojo control because as long as I do not try to send any data to page2.xsp, I can click the "renderResults" button as many times as I like and it always renders correct results. However as soon as I start posting my selection back to the server via the "saveSelection" buton, which POSTs the selection to another xpage -- page2.xsp asynchronously, something goes iffy. After making one to four such posts I can press "renderResults" button, the server side code for this button runs, and I can obtain new results. After the fifth and greater number of such POST requests the server looses the state of my main page and when I press the "renderResults", the server side onclick event no longer runs, and I cannot access the request scope variables even though the firebug says they were posted to the server. Even though the page now renders as if it was in its initial state but whenever I try to input the parameters and press the "renderResults" button, the "renderResults" serverside onclick event no longer runs, which means no results are displayed. To get it work again I have to go to the browser address bar and enter the address again. Then the page loads brand new and the "renderResults" button works as descibed above.