[jboss-user] [JBoss Seam] - Re: many-to-many (dynamically shown) on same JSF page

rhinosystemsinc do-not-reply at jboss.com
Fri Apr 20 14:45:31 EDT 2007


I'd like some help with how the JSF dataTable 
and single/multi selects are setup and how to setup
the SLSB to handle the SAVE on this scenario.

Here are the objects and tables roughed in .

public class Person
{
   String FNAME="";
   List preferences=null;
   @ManyToMany
   @JoinTable (name="Person_SysPref"
            joinColumns=@JoinColumn(name="PERSON_ID"),
            inverseJoinColumns=@JoinColumn(name="PREF_ID"))
    public List getPreferences()
    {
       return preferences;
    }
... w/ getters and setters
}

public class Pref
{
    String name="";
    String selected="";
    String group="";
... w/ getters and setters
}

~ tables ~

create table Person
(
    PERSON_ID number primary key,  -- surrogate generated key by person_seq sequence
    FNAME varchar2(30)
);

create table SysPref
(
    SYSPREF_ID number primary key, -- surrogate generated key by SysPref_seq sequence
    NAME varchar2(30),
    GRP varchar2(20)
);

create table Person_SysPref
(
    PERSON_SYSPREF_ID number primary key,
    SYSPREF_ID number, --fk to SysPref
    PERSON_ID number -- fk to Person table
    selected char(1)
);

The front end :
   a create form to input the Person.FNAME
   and on same form a list of Pref options (derived directly from the SysPrefs table).
 
  Once I hit the "SAVE" button (it is bound to SLSB, not shown here), the Person will be CREATED, and then   I loop though all the "preferences" store all of them in the Person_SysPref  table, with selected flag for that Person.

The concept of "injecting" the Person object into a  SLSB is clear from samples,but how do I get the list of Preferences (available from the SysPrefs)? And then once I have Person object existing, how do I associate this list of Prefs directly with the Person.preferences instead of the SysPrefs?

One last thing - on the UI, I'd like to be able to group the preferences by the GRP value - for example,

colors: (single select radio buttons)
    red
    green
    blue
size: (single select radio buttons)
     small
      med
     lg
Favorite Sports: (multiselect check boxes)
    hiking
    biking
    running  

If you can give me some general direction or even code examples.  on this, I'd really appreciate it.


Thanks again!

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4039385#4039385

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4039385



More information about the jboss-user mailing list