I've been working on a site where people can register. When the users are registering I want them to choose a couple of sub-groups belonging to super-groups. i've created a @OneToMany list in the registration like this:
private List<Subgroup> subgroups;
@OneToMany(targetEntity=com.dorego.sspgis.site.model.Subgroup.class)
public List<Subgroup> getSubgroups() {
return subgroups;
}
public void setSubgroups(List<Subgroups> subgroups) {
this.subgroups = subgroups;
}Now there is not a problem here but in the registration form i need to create multiple supergroup blocks containing sub-groups. I am trying to do that like this:
<ui:repeat value="#{superGroupList.resultList}" var="oneSuperGroup">
<h:outputText value="#{oneSuperGroup.name}" />
<h:selectOneRadio value="#{registration.subgroup}">
<s:selectItems value="#{oneSuperGroup.subgroup}" var="oneSubgroup" label="#{oneSubgroup.title}"/>
<s:convertEntity />
</h:selectOneRadio>
</ui:repeat>which will produce something like the following:
Supergroup 1:
-radiobuttons with subgroups
Supergroup 2:
-radiobuttons with subgroups
etc.
This goes well untill i want to save the form, because then it will try to put multiple Subgroup objects AS a List, which naturally can't be done because they have to be placed IN the list. Now i've tried making it static, by creating a couple of subgroup objects into the registration class. yet this means there can only be a static amount of subgroups which i don't want.
So my question is: Is there a way to put the Subgroup objects into the List when saving the form?
Thanks in advance