Tag Archives: seam

Seam @DataModel Factories

Seam has a great feature called DataModel. In a nutshell, you provide a List, and seam populates a dataTable for you. The great thing about it, is you can provide an injection point marked as DataModelSelection, and when the user clicks on one of the dataTable rows, you have the selected object.

Theoreticaly, you can put the @DataModel annotation on a method or on a field. However, as it turns, by declaring a method as DataModel it will be called for each use of the returned list. This can cause big performance issue, as the list generation often requires fetching the data from back end systems such as the database. The sumple solution for this is to declare the list as a member of the backing bean, and add a factory method for it. In this case, the factory method will be called only when the @DataModel List is null.

For code example, have a look here.