This content has been marked as final.
Show 7 replies
-
1. Re: Is it possible to connect JSF fields to a List of Entity
pmuir Aug 18, 2006 5:42 AM (in response to mrohad)<h:dataTable value="#{elements}" var="element"> <h:inputText value="#{element.foo}" /> <h:inputText value="#{element.bar}" /> </h:dataTable> <h:commandButton action="#{elementManager.save}" />
@Name("elementManager") public class ElementManager { @In(create=true) @Out private List<Element> elements; ... @Factory("elements") public void build() { elements = new ArrayList<Element>(); for (int i = 0; i < 3; i++) { elements.add(new Element()); } } public String save() { Iterator<Element> it = elements.iterator(); while (it.hasNext()) { em.persist(it.next()); } } }
-
2. Re: Is it possible to connect JSF fields to a List of Entity
mrohad Aug 18, 2006 7:14 AM (in response to mrohad)great thanks , is it possible to add another new elmenet by clicking "add" button?(is it possible to do so without calling the server side)
-
3. Re: Is it possible to connect JSF fields to a List of Entity
pmuir Aug 18, 2006 7:17 AM (in response to mrohad)You do need to 'call the server side' I think
public void addElement() { elements.add(new Element()); }
-
4. Re: Is it possible to connect JSF fields to a List of Entity
mrohad Aug 18, 2006 7:40 AM (in response to mrohad)thanks but how does this "add button works? how do I make him add new line to my table that related to this new element?
-
5. Re: Is it possible to connect JSF fields to a List of Entity
pmuir Aug 18, 2006 8:25 AM (in response to mrohad)<h:commandButton action="#{elementManger.addElement}" />
-
6. Re: Is it possible to connect JSF fields to a List of Entity
pmuir Aug 18, 2006 8:35 AM (in response to mrohad)You would also want to make the bean conversational
-
7. Re: Is it possible to connect JSF fields to a List of Entity
mrohad Aug 18, 2006 10:16 AM (in response to mrohad)isn't it possible to do that without calling the server?
injavascript it's easy to create another rown in the table with input fields...but how do I relate those fields to the new element properties?