Announcement Announcement Module
Collapse
No announcement yet.
Binding TextArea to a List Element in a Map Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Binding TextArea to a List Element in a Map

    I'm creating a dynamic form and was hoping to avoid some domain specificity.

    I'm wondering if it is possible to bind the first element of a List<String> that is a value in a Map to a textarea.

    Example Command Object:
    Code:
    public class FormObject(){
         private Map<Integer, List<String>> formMap = new HashMap<Integer,    List<String>>();
    
         public FormObject
    
         public Map<Integer, List<String>> getformMap(){
             return this.formMap;
         }
    
         public void setFormMap(Map<Integer, List<String>> formMap){
              this.formMap = formMap;
         }
    }
    Example JSP (assume 'key' exists in the map with a not null list as a value):

    Code:
         <form:form modelAttribute="formObject">
              <form:textarea path="formMap[key]" />
         </form:form>
    I've also tried the following but I don't even know if its legal:

    Code:
         <form:form modelAttribute="formObject">
              <form:textarea path="formMap[key][0]" />
         </form:form>
    In the past I know I've bound a textarea to the specific elements in a list:

    Code:
         <form:form modelAttribute="someFormObject">
              <form:textarea path="someList[0]" />
         </form:form>
    I can bind the map value to <form:radiobuttons> and <form:checkboxes> without any issue.

    Any advice would be appreciated and I am happy to clarify if this doesn't make sense.

    Thanks!
Working...
X