JSF Notes on Events

About a week ago, I asked a question in this forum concerning JSF events, and how to accomplish a particular task. Apart from using Ajax, no one seemed to know how to accomplish a task that I thought would be fairly easy. Being a fairly stubborn individual, I decided to learn everything there was to know about the JSF lifecycle, order of event firing and related topics. Here is what I discovered:

1.The current state of JSF documentation is inadequate. There are large gaps both in the standard documentation (both javadoc and in the specification) as well as published books and articles concerning certain features.

2.There is no substitute for trying out features. Because of the lack of good documentation, the only way to really determine what is happening is to try out and document behavior. This is time-consuming, but in my experience the only thing that really worked.

3.immediate=�true� is the feature that is (so far) the worst understood and is poorly described in the API. One (generally excellent) book says that the attribute �determines whether or not the component�s input should be converted and validated immediately (during the Apply Request Values phase�)�. Not true�based on testing with Phase Events:

a.When immediate=�true� is applied to a command component, it causes the associated ActionListener to execute at the end of the �Apply Request Values� phase of the lifecycle. Then (and this is the part that is not well documented) FacesServlet goes directly to the �Render Response� phase, bypassing validation and model update. This occurs automatically, without any need for the developer to formally code it.

b.When immediate=�true� is applied to an input component such as a radio or text control, the associated ValueChangeListener executes at the end of the �Apply Request Values� phase as well, but only after the form is submitted (common sense). You must add onchange=�submit( )� to the tag if you want the component change itself to submit the form. The developer must code explicitly to render the response from a ValueChangeListener�if this isn�t done, the next phases (validation and model update) occur normally.

c.If you want a component to directly update the appearance of another component, both must have their immediate attribute set to �true� or the behavior is �unspecified��which means it doesn�t work, at least in the RI. And again, the form must be submitted (absent any Ajax processing to do so)

4.More complex actions (such as updating a GUI component from the model during a ValueChangeListener) require a thorough understanding of how to manipulate the event queue, and should not be undertaken lightly.

I am hoping that by publishing these notes I can help another developer avoid the frustrating hell I've experienced over the past week.