XPage Cheat Sheet #1 - The Page Lifecycle (Update)
Friday, November 6, 2009 at 8:39PM A few weeks ago I wrote a blog outlining the XPage lifecycle. It appears that with 8.5.1 there have been a few changes made. The following is an updated account of the lifecycle.
This example is based upon a single XPage (X) with 2 custom controls (A & B). Controls seem to be processed in the order they are listed.
X.beforePageLoad
A.beforePageLoad
A.afterPageLoad
B.beforePageLoad
B.afterpageLoad
X.afterPageLoad
The next set of events are ONLY executed when a Full or Partial refresh occurs:-
X.afterRestoreView
A.afterRestoreView
B.afterRestoreView
The following now occur every time following the PageLoad or restoreView events
X.beforeRenderResponse
A.beforeRenderResponse (only occured with PageLoad in 8.5.0)
B.beforeRenderResponse (only occured with PageLoad in 8.5.0)
X.afterRenderResponse
A.afterRenderResponse (only occured with PageLoad in 8.5.0)
B.afterRenderResponse (only occured with PageLoad in 8.5.0)
The key difference for 8.5.1 being that the beforeRenderResponse and afterRenderResponse are now executed for the XPage and ALL custom controls regardless of whether a partial refresh or full refresh occurs.
- 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 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.
custom controls,
events,
page lifecycle in
Tutorial 