Wednesday, March 08, 2006

JSF notes on event handling

Three different kinds of listeners:
  • Phase listener -- listener is invoked as jsf goes through each of the 6 phases, you can register for a specific phase or all of them.
  • Action listener -- listener is invoked when an action like command button is clicked.
  • Vlaue change listener -- listener is invoked when an input component like textbox value is entered and form submitted
There is subtle difference between the use of action handlers and action listeners, handlers are meant for business rules, iterfacging with backend systems, and
navigational logic whereas listeners are meant to handle with UI elements only.

Action listeners are invoked before action handlers.

Value change and action listeners can be added as UI element attibutes as well as tags. It is better to add as tags.

Below are the execution of different phases for different scenarios:
  • value change listener --> 1 -- 2 -- 3 (listener called) -- (4 -- 5 -- 6)
  • value change listener with immediate --> 1 -- 2 (listener called) -- 3 -- (4 -- 5 -- 6)
  • action listener --> 1 -- 2 -- 3 -- 4 -- 5 (listener called) -- (6)
  • action listener with immediate --> 1 -- 2 (listener called) -- (6)

No comments: