This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes lifecycle and action events question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "lifecycle and action events question" Watch "lifecycle and action events question" New topic
Author

lifecycle and action events question

Anthony Taylor
Greenhorn

Joined: May 04, 2006
Posts: 26
I have an action connected to a commandButton and was wondering where in the lifecycle actions occur. It appears as if they run right before render response, though I could be mistaken. Is there a way to have it trigger, say, after UpdateModelValues() phase. When I make the post, the only item that changes is the value of a hidden field, everything else remains the same. For some reason, it seems like the lifecycle is not running its course. What differentiates postback requests from get requests and what factors into the distinction. Basically, I would like for it to go through the complete lifecycle when the post occurs. Any ideas on what I could be doing wrong?
Hung Tang
Ranch Hand

Joined: Feb 14, 2002
Posts: 148
Originally posted by Anthony Taylor:
[QB]I have an action connected to a commandButton and was wondering where in the lifecycle actions occur.

Just as you suspected, right after update model as part of "invoke application" phase.


What differentiates postback requests from get requests and what factors into the distinction. Basically, I would like for it to go through the complete lifecycle when the post occurs.

JSF has 6 phases that forms the lifecycle. GET requests go from restore view (phase 1) and jumps to render response (phase 6) where as a faces requests (POST) will go through all phases. Now you just have to be aware that interruption can happen in the life cycle, so some phases will be skipped. For example, if validation fails (which happens in phase 3), then phase 4,and 5 will be skipped.

I suggest you create a simple phase listener (go google it), so you get a clear idea how JSF internal works.
Anthony Taylor
Greenhorn

Joined: May 04, 2006
Posts: 26
With that said, I attached the afterPhase event to my f:view tag for my jsp page. Now I tried one post attached to an event and I tried to just post the form using javascript. Now in both cases it is skipping to Render Response and bypassing the other phases. With what you just mentioned, if I dont trigger the post through an action shouldn't it go through the whole lifecycle if I just post the form instead, as long as there are no validation errors that is.
Hung Tang
Ranch Hand

Joined: Feb 14, 2002
Posts: 148
Does the logs give you any clues?

Like I said, implement a full Phase Listener, and see the logs where you are going wrong.

This is a good article read:
http://www.jroller.com/page/cschalk?entry=getting_familiar_with_the_jsf
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: lifecycle and action events question
 
Similar Threads
Calling a backing bean function when inputtext value changes
How to define String array in the <s:param/> tag?
h:commandButton not working
Interceptors
PreDestroy callback function in action controller bean?