Does anyone know if any detailed documentation exists of the page lifecycle for an Xpage? By that I mean from the time the page is created until the page is destroyed what events get fired and when along with milestones such as state and access to the HTML. I am …Domino Development / XPages
Show Correct Answer...
From Peter Presnell - http://www.bleedyellow.com/blogs/dotdomino/entry/xpage_cheat_sheet_1_the_page_lifecycle5?lang=en
There seems to be a lot of essential documentation about XPages missing from the on-line documentation. One of the key items I have been searching for is a description of the page lifecycle for an XPage. After performing some experiments I have mapped out the following basic lifecycle. I will try and expand on it as time and the need dictates....
The following example is based upon a single XPage (X) with 2 custom controls (A & B).
Note: (controls seem to be processed in the order they are listed)
The following are executed ONCE only:-
The next set of events are ONLY executed when a Full or Partial refresh occurs:-
if any control events have been fired they are then executed here.....
The following occur next, although it is not yet clear if this exact pattern is always repeated for Full & Partial Refreshes.
A.beforeRenderResponse (only appears to occur with PageLoad)
B.beforeRenderResponse (only appears to occur with PageLoad)
A.afterRenderResponse (only appears to occur with PageLoad)
B.afterRenderResponse (only appears to occur with PageLoad)
So what exactly does this mean?
- PageLoad events are a good place to place code you only wish to execute the very first time the page is created.
- afterRestoreView events seem to be the best place for code that you wish to execute each time a refresh occurs.
- Events on a page/control will execute after the afterRestoreView events have fired so they will have access to any variables/object you create in these events.
- To have code execute every time the page is processed you probably need to place it in a PageLoad and an afterRestoreView event
- Wen placing code in a control's afterPageLoad event don't assume the beforePageLoad events of the other controls have fired or that the page's afterPageLoad has fired.