View RSS Feed

JSF

JSF Action Events

Rate this Entry
by
JSF
, 07-07-2012 at 05:54 PM (765 Views)
For UI Command objects, emission of the action events takes place. When Command button is pressed by a user or a hyper link is clicked, generation of such events take place. Number of listeners could be attached to the source. For instance, let us consider the given code:

Java Code:
<h:commandButton value = "Test Action Listener"
actionListener = "#{testActionListener.doSomeAction}" />
An attribute known as actionListener is defined that point towards the method expression. Such method expression would be resolving towards method known as doSomeAction() that has been defined in the Managed Bean along with TestActionListener.

Java Code:
public void anyMethod(ActionEvent actionEvent)
Managed Bean definition is given below in the Faces Configuration file,

XML Code:
<managed-bean>
    <managed-bean-name>testActionListener</managed-bean-name>
        <managed-bean-class>
                  TestActionListener
        </managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
</managed-bean>
Two listeners are attached by this given code to the component that has been made identified by the help of myComponent.

Java Code:
UIComponent myComponent = new UIComponent();
myComponent.addActionListener(new TestActionListener());
myComponent.addActionListener(new CustomActionListener());

Submit "JSF Action Events" to Facebook Submit "JSF Action Events" to Digg Submit "JSF Action Events" to del.icio.us Submit "JSF Action Events" to StumbleUpon Submit "JSF Action Events" to Google

Categories
Event

Comments