Using component data binding

Top  Previous  Next

Components can be used with models data binding with the help of JSF Managed Beans.

 

To use the data binding with JSF managed beans the below steps should be accomplished:

 

1.Create the bean class:

 

       public class MyTableBean {

 

               TableDataModel dataModel = new TableDataModel();

               ...

 

               public TableDataModel getDataModel() {

                       return dataModel;

               }

               ...

       }

 

2.Define managed beans in the faces-config element of your application.

 

       <managed-bean>

               <managed-bean-name>TableModelBean</managed-bean-name>

               <managed-bean-class>testingapplication.table.MyTableBean</managed-bean-class>

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

       </managed-bean>

 

3.Define some model tag on JSP page to specify which property binding to use. For more information on using managed beans see JSF documentation.

 

      <table:table id="table1">

          <table:tableData model="#{TableModelBean.dataModel}"/>

          <table:tableColumn columnSelectionModel="#{TableModelBean.columnModel}"/>

          <table:tableInterfaceManager model="#{TableModelBean.nonHighlightInterfaceManagerModel}"/>

          <table:header model="#{TableModelBean.headerModel}"/>

      </table:table>

 

You can see the managed bean example for table component in the testing application demo (sample_binding.jsp).