Help

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

JSF does not cache the results of executing EL value expression. Therefore, you will find that typically a single EL value expression will result in the getter being called at least once, but probably two or three times. Further, if you are using a JSF control which involves some sort of iteration (like <h:dataTable />, <h:selectOneMenu /> etc.) then some value expression will probably called once for each iteration.

What can you do? Make sure your getters are lightweight, and use some sort of lazy initialization.

For example, this would result in your list being built many times:

@Name("fooManager")
@Scope(EVENT)
public class FooManager {

   public List<Foo> getFoos() {
      return createFooList();
   }
}
<h:dataTable value="#{fooManager.foos}">
   ...

but this simple change fixes the problem:

@Name("fooManager")
@Scope(EVENT)
public class FooManager {

   private List<Foo> foos;

   public List<Foo> getFoos() {
      if (foos == null) {
         foos = createFooList();
      }
      return foos;
   }
}