The
onConstructionFunction JSF handler
property specifies a function within the JSF handler that runs when
the page is first constructed. (This property was formerly known as
onPageLoadFunction.)
More accurately, the function runs when the page bean (representing
the JSF handler in the web server) is instantiated (created).
- For pages with session scope, the page bean is created only the
first time the user visits the page.
- For pages with request scope, the page bean is created again each
time the user visits the page.
- If the JSF handler's cancelOnPageTransition property
is set to YES, the page bean is removed from the session when the
user moves to another page, even if the scope property
is set to session. Thus the page bean is
created again the next time the user visits the page.
The specified function runs when another JSF handler or program
forwards control to the JSF handler. This function does not run again
if the JSF handler forwards control to itself or if a function within
the JSF handler ends without issuing a forward statement.
Compare with the following related properties:
- onPreRenderFunction, which specifies
a function that runs before the page is rendered in memory.
- onPostRenderFunction, which specifies
a function that runs after the page is rendered in memory, but before
the page is output to the screen.
If you specify parameters for any of the functions these properties
refer to, you must specify the same parameters for all of the functions.
If you use session scope and set
cancelOnPageTransition to
NO, JSF places the handler in session, where it will stay until it
times out or the session ends. The handler can contain data for unused
fields, or other unnecessary information. You might be able to save
memory by doing the following:
- Use request scope.
- Explicitly save all data that needs to persist beyond the end
of the request.
- Restore the data in the function specified by either onConstructionFunction or onPreRenderFunction.
You can explicitly remove a page from session scope with the j2eeLib clearSessionAttr() and clearEGLSessionAttr() functions
(see clearSessionAttr() and clearEGLSessionAttrs()).