Anissa Lam wrote:
>
> I have 2 questions regarding intiPage events.
> - How can i tell what phase the initPage events is happening ? ie,
> whether it is beforeCreate, or it is during the 're-rendering' (i am
> not sure the exact term) thats triggered by pressing a submit button.
The initPage happens during the Restore View phase. The Restore View
phase does 1 of 2 things: 1) Creates a view (createView) or 2) restores
an existing view (restoreView).
Case 1:
You navigate to a new page either directly via the browser by typing in
a new URL, or by forwarding / redirecting to a different page via code.
In either case, this will case "createView" to be called and therefor
your initPage event.
Case 2:
You will restore an already created view anytime you submit a JSF form
back to the same page. This form must include state information in
order for it to be recognized as requesting the same page (this includes
server-side state saving, the form submits an ID which must match the
server-side or it will create a new view). In this case, restoreView is
called and therefor your initPage event.
So... you can expect initPage to be called at the beginning of any
request to a page regardless of whether it is a post back to the same
page, or a new request. You can also expect it to be called when you
navigate to the page from the server-side.
Ken
> - If the initPage event is in the 're-rendering' phrase, how can i
> tell which button triggers that if there are several buttons on the
> page ?
It's not during "rendering", but during restoring the "page". This
event cannot be associated with a button, it is always associated with a
*page*. This also brings up the requirement that you must declare it at
the page level... if you put it under any component it will be ignored.
I hope this helps!
Ken
>
> thanks
> Anissa.