Using all listeners for all events of components as JSF Managed Beans

Top  Previous  Next

To use the listeners as JSF managed beans the below steps should be accomplished:

 

1.Create the listener class. For example:

 

public class MyMenuItemSelectedListener extends MenuItemSelectedListener

{

...

}

 

2.In the faces-config element of your application configuration file define the managed beans.

 

<managed-bean>

<managed-bean-name>myMenuItemSelectedListener</managed-bean-name>

<managed-bean-class>testingapplication.menu.MyMenuItemSelectedListener</managed-bean-class>

<managed-bean-scope>session</managed-bean-scope>

</managed-bean>

 

3.Define component tag on JSP page to specify which listener property to use.

 

<menu:menu id="menu2" menuLabel="Root0" menuAbsolutePosition="false"

menuItemSelectedListener="#{myMenuItemSelectedListener}">

 

You can see the managed bean example for each component in the testing application demo.