Using all models for all components as JSF Managed Beans

Top  Previous  Next

You can use all models in all components as JSF Managed Beans.

 

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

 

1.Create the model class:

 

public class TreeDataModelBean extends BaseTreeDataModelImpl

{

...

}

 

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>

 

3.On JSP page define some model (e.g. dataModel) tag to specify which property beanName to use. For more information on using managed beans see JSF documentation.

 

<tree:dataModel beanName="#{myTreeDataModelBean}" scope="session"/>

 

4.On JSP page you can retrieve the property from managed bean by using the following syntax:

 

value="#{beanName.propertyName}"

 

 

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