JSF - Listener

Java Conceptuel Diagram

About

Listeners are used to listen to the events happening in the page and perform actions as defined.

An application developer can implement listeners as:

Referencing a Method That Handles

an Action Event

If a component on your page generates an action event, and if that event is handled by a managed bean method, you refer to the method by using the component’s actionListener attribute.

The following example shows how such a method could be referenced:

<h:commandLink id="Duke" action="bookstore"
     actionListener="#{actionBean.chooseBookFromLink}">

The actionListener attribute of this component tag references the chooseBookFromLink method using a method expression. The chooseBookFromLink method handles the event when the user clicks the hyperlink rendered by this component.

a Value-Change Event

If you want a component on your page to generate a value-change event and you want that event to be handled by a managed bean method instead of a ValueChangeListener implementation, you refer to the method by using the component’s valueChangeListener attribute:

<h:inputText id="name"
             size="30"
             value="#{cashier.name}"
             required="true"
             valueChangeListener="#{cashier.processValueChange}" />
</h:inputText>

The valueChangeListener attribute of this component tag references the processValueChange method of CashierBean by using a method expression. The processValueChange method handles the event of a user entering a name in the input field rendered by this component.

Documentation / Reference





Discover More
Jdeveloper Create Managed Bean
JSF - (Managed Bean|Controller)

Managed Beans (also known as model objects and controllers) are lightweight container-managed objects (POJOs) with minimal requirements. They support a small set of basic services, such as: resource...
Java Conceptuel Diagram
Java - Server Side Components

Server-side components enable application developers to develop “business logic” and package it as a component that can be assembled into applications. JSF server-side objects: managed beans,...
Java Conceptuel Diagram
JavaServer Faces (JSF)

The request: means to maintain the state for the time of a request session: means to maintain the state for the time of a session (between page views) none: means that the bean will be created but...



Share this page:
Follow us:
Task Runner