|
Using component selection and data models as Managed Beans |
|
You can use selection and data models in Tree component as JSF Managed Beans.To accomplish that the below steps should be followed.
| 1. | Create the selection and data models. |
| 2. | In the faces-config element of your application configuration file define the managed beans: |
<managed-bean>
<managed-bean-name>myTreeDataModelBean</managed-bean-name>
<managed-bean-class>testingapplication.tree.TreeDataModelBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>myTreeSelectionModelBean</managed-bean-name>
<managed-bean-class>testingapplication.tree.TreeSelectionModelBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
| 3. | Define dataModel and selectionModel tag to specify which property to use. For more information on using managed beans see JSF documentation. |
<tree:dataModel
beanName="#{myTreeDataModelBean}"
scope="session"/>
<tree:selectionModel
beanName="#{myTreeSelectionModelBean}"
scope="session" />
You can see the managed bean example for Tree component in the testing application demo.