1 Reply Latest reply on Jan 30, 2007 1:47 PM by Gavin King

    Problem with Backing Bean method being called multi-times

    Eric Yip Newbie

      Hi,

      I'm a newbie in seam, jsf, and all that jazz...

      I've created a simple application and it's running fine with one exception.
      The method in my backing bean that returns a list of items to display is being
      called ONCE per LOOP in my jstl <c:forEach> loop. This is very inefficient as this
      method is hitting the database every loop.

      1) My question is why is that method being called every loop iteration. Shouldn't it be
      called only once in the loop?

      2) Am I doing something that I should not? If yes, can anyone tell me the right
      way of doing this.


      Any suggestions is highly appreciated !!


      Backing Bean snippets...

      @Name("FooBean");
      @Scope(ScopeType.EVENT)
      public class FooBean {
      ...
      public List getFooList() {
      // This method retrieves data from database and return it.
      }
      ...
      }

      xhtml JSTL snippets:
      <c:forEach items="${FooBean.fooList}" var="foo">
      <!-- Display them -->
      </c:forEach>

      Thanks.