views:

34

answers:

1

At which phase of the JSF request processing lifecycle, the backing bean method marked with @PostConstruct called?

+2  A: 

Methods marked with the @PostConstruct will be invoked after the bean has been created, dependencies have been injected, all managed properties are set, and before the bean is actually set into scope.

Found related SO thread, might not be exactly same but it answers your question. And a blog entry explaining the same.

Adeel Ansari
This answer (and the mentioned block entry) associates the @PostConstruct with the lifecycle of the bean itself. But I want to associate it with the JSF request processing lifecycle events (restore view, apply request values, process validation... in this order when the @PostConstruct comes)
MISS_DUKE
@MISS_DUKE: If the bean has request scope, @PostConstruct will get executed on every request in the way, I mentioned in my post.
Adeel Ansari
Thanks for your clarification, but I search for more refined information. If it is a requested scoped backing bean (@PostConstruct will get executed on every request, as you have mentioned), at what stage the @PostConstruct executed? Is it executed just after/before the "restore view" phase? Or just after/before the "apply request values" phase? Or just after/before the "validation" phase?
MISS_DUKE
@MISS_DUKE: It is executed in the same phase where it is instantiated. Hence, for the first time, when its not already created and attached to the context, it may be the Apply request view phase.
Adeel Ansari