JSF Event Listeners
by, 07-07-2012 at 04:56 PM (577 Views)
When a link or button is clicked by a user, values present in a field get changed or a selection is made in list so that the application might react. Interface components of JSF User would signal certain user action when an event is fired that is being handled by the code.
Event listeners that are very commonly used are value change and action. Others like phase or data model would not be discussed over here. In separate listener or managed bean, it is possible to declare the listeners. When listeners are placed in separate classes then reusage is allowed across various page views. Creation of the listener class shall be implementing the ValueChangeListener or ActionListener. As it has been described before that only taken parameter by the listener is FacesEvent object. Information is provided by FacesEvent regarding event like form element which makes the event initiation and also the phaseId relevant to the life cycle phase of JSF. Two sub interfaces are present in FacesEvent, ValueChangeEvent and ActionEvent.