Results 1 to 1 of 1

Thread: Multi-value field in webflow

Threaded View

  1. #1
    Join Date
    Mar 2010
    Posts
    7

    Default Multi-value field in webflow

    I have a specific use case where a domain entity contains a few properties that contain multiple values. More specifically I need to have an enter form where an unlimited number of phone numbers can be attached to a person.

    I imagine this use case it pretty common - as another example would be multiple attachments on a e-mail form.

    Putting the phone number on a view by itself is possible but not what the client has requested.

    Code:
    public class Person{
      private String name;
      private List<String> phoneNumbers;
    
      //getter/setter for name
    
      public List<String> getPhoneNumbers(){
        return this.phoneNumbers;
      }
      public void addPhoneNumber(String phoneNumber){
        this.phoneNumbers.add(phoneNumber);
      }
    }
    HTML Code:
    <form:form commandName="person">
      <form:input path="name" />
    
      <input name="phoneNumber" type="text" value="" />
      <input type="button" value="Attach Phone Number" />
      <c:forEach items="${person.phoneNumbers}" var="phoneNumber">
        <c:out value="${phoneNumber}" />
      </c:forEach>
      <input type="submit" value="Next" />
    </form:form>
    Last edited by jaredp; Apr 1st, 2010 at 05:05 AM. Reason: Fixed a grammatical error

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •