8 Replies Latest reply on Aug 19, 2007 5:57 PM by pmuir

    rich:datatable java.util.Set interface support

      Does datatable support java.util.Set interface for value tag?

      I try with this example and dosen't work.

      public class Person {

      private String name;

      public String getName() {
      return name;
      }

      public void setName(String name) {
      this.name = name;
      }


      }

      @Name("backingBean")
      ...
      private Set persons;
      public Set getPersons() {
      return persons;
      }

      public void setPersons(Set persons) {
      this.persons = persons;
      }

      <r:dataTable value="#{backingBean.persons}" var="v">
      <r:column>
      <t:outputText id="outIdentValue" value="#{v.name}" />
      </r:column>
      </r:dataTable>


      Will this be included in new release or??
      Should I report as jira issue??????

        • 1. Re: rich:datatable java.util.Set interface support

          does the standard h:dataTable support Set ?

          • 2. Re: rich:datatable java.util.Set interface support

            No it does not. The reason is that DataTable need ordered list, it require access by index. Set is unordered connection of unique elements, access my index is impossible.

            At tye same time somethig as simple as

            public List getPersonsList() {
            Lis ret = new ArrayList();
            ret.addAll(getPersons())
            return ret;
            }

            Can serve the purpose.

            • 3. Re: rich:datatable java.util.Set interface support

              One year ago, we work with tomahawk and they didn't support set interface so we "decanting" from set to list. Utterly stupid and unnecessarily job (my opinion). Then Tomahawk start to support set interface and all our job mean nothing and of course nobody bothered with old code. The reason why to use set is interaction with hibernate.

              When you work with hibernate and list its require another index column in table (by my opinion, unnecessarily). Simple way is to use LinkedHashSet because it's leave same order as it gets from database and that order could be set by mapping.

              example

              @OneToMany(mappedBy = "nadGrana", fetch = FetchType.LAZY)
              @OrderBy("id")
              public Set getPodGrane() {
              return podGrane;
              }

              Now is critical moment to choose tomahawk datatable or rich datatable.

              Now, I wonder how did team at tomahawk implemented set interface, hope they didn't "decanting" from set to list..

              • 4. Re: rich:datatable java.util.Set interface support

                After consulting with my team member who work with model, we try to simple use List interface to get data from database and IT'S WORK :), so that mean's EJB 3 does this internaly and it's no longer problem.

                In hibernate there was need to have index field in database when using List, but now in EJB 3 its no longer necessary, now we know that :)

                Before, in hibernate we must use something like this (hbm)

                <set name="stavke" cascade="delete-orphan" lazy="false"
                order-by= "sifra asc">

                <one-to-many class="orka.mkor.mapping.dokumenti.robni.InventuraStavka"/>



                Now, analogue, we tried this, and it's conflict with rich:datatable

                private Set podredeni = new LinkedHashSet();

                @OneToMany(mappedBy = "nadredeni", targetEntity = SimpleSifarnik.class)
                @Filter(name="time", condition="datumKreiranja <= :time")
                @OrderBy("id")
                public Set getPodredeni() {
                return podredeni;
                }

                public void setPodredeni(Set podredeni) {
                this.podredeni = podredeni;
                }


                Now, after just use List everiting work just fine

                private List podredeni = new Vector();

                @OneToMany(mappedBy = "nadredeni", targetEntity = SimpleSifarnik.class)
                @Filter(name="time", condition="datumKreiranja <= :time")
                @OrderBy("id")
                public List getPodredeni() {
                return podredeni;
                }

                public void setPodredeni(List podredeni) {
                this.podredeni = podredeni;
                }

                • 5. Re: rich:datatable java.util.Set interface support

                  I guess we still have open question to support Set in Data Table

                  • 6. Re: rich:datatable java.util.Set interface support

                    I think you should support Set!

                    • 7. Re: rich:datatable java.util.Set interface support
                      budoray

                      Supporting Set would allow us make use of the java.util.concurrent package.

                      • 8. Re: rich:datatable java.util.Set interface support
                        pmuir

                        +1

                        Is there a JIRA issue for this

                        (n.b. Seam has a SetDataModel which could be used).