12 Replies Latest reply on Nov 14, 2008 3:46 PM by Florian Bantner

    more foreach stuff - performance

    Florian Bantner Newbie

      Hello again,


      since foreach now (nearly) works as expected there is another issue which trouble me:


      Following code:


      <c:forEach items="handler.getList()" var="item">
      
         #{item.title}
         #{item.teaser}
         #{item.xyz}
         ...
      </c:forEach>
      



      results in multiple calls to handler.getList(). In this example these are: handler.getList()...getTitle(), handler.getList()...getTeaser(), hander.getList()...getXyz()


      I guess ... stands for some index access to the list ( get(0), get(1), get(2), etc.).


      The resulting amount of calls to handler.getList() is therefore the number of list entries x number of accesses to an list member.


      In my case this are about 50x40 equals 2000 per page. Which in turn means 2000 in-/outjection circles, list accesses, method calls, etc.


      What makes that even worse is that my getList() method generates the list depending on context variables every time the method is called.


      I could implement some kind of caching. But it would be better, if there was some way of simply reducing this mess to only one call.


      I've tried using c:set but with no change in behaviour.


      Does anyone have a solution for that?


      Thank you very much.