Announcement Announcement Module
No announcement yet.
Spring + JQuery dynamic list bind Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring + JQuery dynamic list bind

    I am new to Spring and still learning. I want to make some more advanced form handling.

    Currently my problem is dynamic list binding.

    I want to have one text box, one list and add button. What is scenario?
    User populates text box(with autocomplete) and cliks add button. After initiation add action, list gets populated without issuing request to server.
    User adds few more items to list, and then submits form to server.

    What is problem?

    I dont know how to bind list or pass dynamic data to server.

    Currently I have managed to get JSON response from Controller with list for autocomplete.

    Is Spring forms suitable for this task? What is the right way to implement this?

  • #2
    When you say "list" do you mean a <select> html element with the ability to select multiple elements or are you just talking about a html list? I can think of a few ways you could implement this.

    What data type are you trying to bind to? Is it a List<String> or what?


    • #3
      I think your problem is that how to transfer data from java to JS, then you can use Jquery to build html element, right?


      • #4
        the anser to this is simple thougn not obvious: change your javascript code to generate this "<form:textarea path="youCommandProperty/>" when you submit your form the youCommandProperty field will have the values the user has entered seperated with comma.You split the String and you have your values!