Using event listeners as Managed Beans

Top  Previous  Next

To use the listener as JSF managed bean, the below steps should be accomplished:

 

1.Define the managed bean in the faces-config element of your application configuration file .

 

<managed-bean>

       <managed-bean-name>myTreeLeafSelectedListener</managed-bean-name>

       <managed-bean-class>testingapplication.tree.MyTreeLeafSelectedListener</managed-bean-class>

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

</managed-bean>

<managed-bean>

       <managed-bean-name>myTreeBranchSelectedListener</managed-bean-name>

       <managed-bean-class>testingapplication.tree.MyTreeBranchSelectedListener</managed-bean-class>

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

</managed-bean>

 

 

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

 

<tree:tree id="frameWorkContent"

               varName="frameWorkContent"

               treeLeafSelectedListener="#{myTreeLeafSelectedListener}

 

               treeBranchSelectedListener="#{myTreeBranchSelectedListener}">

 

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