This content has been marked as final.
Show 3 replies
-
1. Re: Capture all inputs related to OneToMany relationship in a single form
tmalatinszki Sep 17, 2009 12:30 PM (in response to evejeba)Hi Evelyn,
You shold use <a4j:repeat> in this case.
<h:inputText value="#{person.name}"/> <a4j:repeat value="#{person.emails}" var="email"> <h:inputText value="#{email.emailAddress}"/> </a4j:repeat>
Regards,
Tamas -
2. Re: Capture all inputs related to OneToMany relationship in a single form
evejeba Sep 17, 2009 1:34 PM (in response to evejeba)Thanks Tamas for your inputs.
I would like to provide a static list of 3 input text fields for the user.
The above code doesn't generate the text fields since the #{person.emails} is empty initially.
I would like to somehow associate the above input text fields dynamically to emailHome.instance. How do I achieve that. -
3. Re: Capture all inputs related to OneToMany relationship in a single form
tmalatinszki Sep 17, 2009 2:24 PM (in response to evejeba)
The above code doesn't generate the text fields since the #{person.emails} is empty initially.It's easy to handle: add two new Email entitites to emails list at the beginning, and the code will generate the two (initially empty) input fields for emails. The only thing You have to care about is removing empty Email entities before saving Person entity.
I think it's a better solution than using any kind of static fields (if You want to store five emails instead two, You only need to change a single number in Your java code instead modifying xhtml+java code also), and doesn't requires extra temporary variables neither, because in this case all email input fields binded directly to Person entity's emails variable.Regards,
Tamas