6 Replies Latest reply on Aug 30, 2008 3:59 PM by pmuir

    Foreign key and facelet

    mono

      Hello seamers!
      I'm making my first steps in seam (i'm very newbie ;-) and i want to avoid some headaches.
      A simple example for my question:
      Supose that i have two entityes, Person and Country.
      The entity Person have some atributes, like name, surname, etc, and have an atribute @ManyToOne to the Country table.
      That is:



      @Entity
      public class Person implements Serializable {
      
      private String name;
      .....
      private Country countrycod;
      ....
      /* getters and setters */
      ....
           @ManyToOne @NotNull
           public Country getCountrycod() {
                return this.countrycod;
           }
      .....



      Then if i use seam generate-ui or the 'Seam Generate Entities' from Jboss Tools, the generated Edit.xhtml contains an <rich:dataTable>
      with some tabs for each one of my foreign keys.
      How can i do this in another way?
      It means, supose that i want and edit form like this:



      • Name

      • Surname

      • Country

      • City

      • Street



      if i don't want the Country field below all remainig fields (like seam-gem does)?
      I see some options to achieve it:
      1)May be I coud have a dynamic combo box that add his values from the Country table. How can i do that?
      2)Coud I have a new web window prompt to select the value?
      3)Coud I have some Rich Faces or ajax component like suggestion box?
      4)Any other way?



      I hope that you can help me...
      Thanks,
      Mono.

        • 1. Re: Foreign key and facelet
          nickarls

          I suggest playing around with the samples provided with Seam and then return for some more specific questions.

          • 2. Re: Foreign key and facelet
            mono

            Hi Nicklas,



            I suggest playing around with the samples provided with Seam and then return for some more specific questions.

            I'm read and continue reading the reference documentation...


            The Registration example not cover relations between tables.
            The Message example is about query data using EJB-QL or HQL and display it.
            The Todo list example is about jBPM.
            The numberguess example is about jPDL and pageflow.
            The Hotel Booking example is great, but is not the simpler example to start!
            and the following examples covers other topics, like hibernate, converstations, deploy to tomcat, etc.


            None of this examples respond my simple, and i think specific, question about how to select one of the foreign key present into an entity.
            Sorry for my english, is not the better.
            If you have some example where do that i want in a very simple way, please tell me.
            May be i need to see more deeper the Hotel Booking example... in this example the book.xhtml page include an Hotel as a foreign key.


            Thank you

            • 3. Re: Foreign key and facelet
              nickarls

              Have a look at the seamdiscs example. <Artist, Disk> has a bidirectional 1-to-n relationship

              • 4. Re: Foreign key and facelet
                nickarls

                You might want to popup a shuttle list if you are using RichFaces.

                • 5. Re: Foreign key and facelet
                  cbredesen

                  I came across this as well and I'm interested to know why this design choice was made.  The rich tabbed selection paradigm is interesting but it's so much more complex (and at times cumbersome to use) than a simple HTML select.  I surely may be missing something, though.  It would also be nice to know if there's some way to hint Seam to create the select rather than the tabs.


                  -Chris

                  • 6. Re: Foreign key and facelet
                    pmuir

                    We could certainly support this behaviour - open a JIRA issue.