1 Reply Latest reply on Sep 16, 2008 1:25 PM by Mark Teichmann

    How to bind selectManyListBox to Seam Entity with special boundary conditions?

    Mark Teichmann Newbie

      I have three tables Person, Team and CollectionPersonTeam. When a person is member of a team then a new entry in table CollectionPersonTeam is generated. The seamgen generated XHTML creates rich:tabs with subviews for this but I need to fill in these values in one single page if possible.

      In my generated entities the Person entity looks as follows:

      @Table(name = "Person", schema = "dbo")
      public class Person implements java.io.Serializable {
      private Set<CollectionPersonTeam> collectionPersonTeams = new HashSet<CollectionPersonTeam>(0);
           @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "person")
           public Set<CollectionPersonTeam> getCollectionPersonTeams() {
                return this.collectionPersonTeams;
           public void setCollectionPersonTeams(
                     Set<CollectionPersonTeam> collectionPersonTeams) {
                this.collectionPersonTeams = collectionPersonTeams;

      My XHTML roughly contains this:

      <s:decorate id="teamDecoration" template="layout/edit.xhtml" for="teamListBox">
                   <ui:define name="label">#{messages['TEAM']}</ui:define> 
             <h:selectManyListbox value="#{personHome.instance.collectionPersonTeams}" id="teamListBox">
                  <s:selectItems value="#{teamList.resultList}" var="team" label="#team.name}" />

      Now I am trying to build an XHTML page which contains a selectManyListBox where I can select many teams from table Team. These teams now should end up in new entries in table CollectionPersonTeam after using entityHome.persist from my Person object.
      It is obvious that the code above cannot work because I cannot put a team object into a field of type collectionPersonTeam.

      Should I go for a custom converter or should I use an additional bean to hold the values and let it persist my person entity or what else could I do? I tried building a converter but ended in several problems which I can show in more detail if using a converter really is an option here.

        • 1. Re: How to bind selectManyListBox to Seam Entity with special boundary conditions?
          Mark Teichmann Newbie

          I will try to use the following approach now:

          - create a SFSB that acts as value for the selectManyListBox
          build a custom converter which turns the id of a TEAM into an object of CollectionPersonTeam (for a given person) and returns the team id for a given CollectionPersonTeam

          create a Service that
          - retrieves all CollectionPersonTeams for a given person
          - fulfils CRUD operations on CollectionPersonTeam when called wiht a person and a team as parameter

          Do you think this will work? Or can I use the existing EntityHome and EntityList objects generated by Seam gen instead of a Service?