2 Replies Latest reply on Jul 17, 2007 10:25 AM by Ning Zhao

    dynamic filtering of resultlists

    Simon Bailey Newbie


      is there any way to dynamically filter a resultlist in a JSF view? i have a query that returns lectures which i'd like to display by semester (which is a column in the table). coming from ASP i know there's a method on the RecordSet object which lets you define a sql where-clause as a sublist criteria without a database round-trip.

      is there anyway to do this with seam and jsf?

      and if this is a stupid question, please tell me so -- my workaround at the moment would be to create multiple entityqueries for each sublist.


        • 1. Re: dynamic filtering of resultlists
          Ning Zhao Apprentice

          I would take this approach:

          make a collection of lectures in the semester entity like this:

          public class Semester implements Serializable{
          //I assume the semester and lecture is n:n so needing a linking entity called
          // SemesterXLecture
          private Set<SemesterXLecture> lectures;
          @OneToMany // lazy or eager as you wish, I would prefer eager here
          public Set<SemesterXLecture> getLectures(){
           return this.lectures;

          Then, in one of your conversation beans, load all Semesters and cache them. Then, you can use


          anywhere in your conversation beans. You can also hood a semester in your xhtml file and use it similar to this code:

          <h:dataTable value="#{someManager.semester.lectures}" var="lecture">
          <h:outputText value="#{lecture.desc}" />

          so the lecture changes "dynamically" if you change the semester.


          • 2. Re: dynamic filtering of resultlists
            Ning Zhao Apprentice

            sorry for my typos in the last post. I meant to cache all the semesters in a stateless bean, but not conversation bean.