-
1. Re: AJAX question: how to dynamically add fields to a form?
samdoyle Jul 31, 2007 8:57 PM (in response to smokingapipe)Um, off hand I think you would have to use some DHTML to do this and not necessarily use AJAX. I never tried doing that before with JSF components so I don't know how that would work since the the DHTML is primarily all client side and JSF requires the backing beans and in Seam's case EJB.
-
2. Re: AJAX question: how to dynamically add fields to a form?
smokingapipe Jul 31, 2007 9:16 PM (in response to smokingapipe)Actually I mean DHTML, not AJAX.
Anyway, in this case, it might be better for me to have a scrollable panel that opens up, and provide a couple hundred number fields, and be done with it. Easy to implement, and if we need something more advanced later, I'll change it. -
3. Re: AJAX question: how to dynamically add fields to a form?
damianharvey Aug 1, 2007 5:27 AM (in response to smokingapipe)You could do this easily with Ajax4JSF if you wanted to (if you're using Richfaces then you're already using this). Several advantages over DHTML eg. server-side validation, not trusting the client...etc.
Say you had a Bean called MySerialNumbersBean and it had a List of Serial numbers called mySerialNumbers (with the getters and setters). In your page you would have something (roughly) like this:<s:div id="serialNumbersDiv"> <ui:repeat value="#{mySerialNumbersBean.mySerialNumbers}" var="serialNumber"> <h:inputText id="serialNumber" value="#{serialNumber}"> <a4j:support event="onblur" action="#{mySerialNumbersBean.mySerialNumbers.addSerialNumber()}" reRender="serialNumbersDiv"/> </h:inputText> </ui:repeat> </s:div>
Where all the addSerialNumber() method did was a add(""). You could do this directly from the EL I suppose.
Cheers,
Damian.