[jboss-user] [JBoss Seam] - Re: AJAX question: how to dynamically add fields to a form?

damianharvey do-not-reply at jboss.com
Wed Aug 1 05:27:36 EDT 2007


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.

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

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



More information about the jboss-user mailing list