lundi 20 avril 2015

How to bind input elements to an arraylist element in Spring MVC?

How to bind input elements to an arraylist element in Spring MVC?

The view model:

public class AssigneesViewModel {

    private int evaluatorId;
    private int evaluatedId;
    private String evaluatorName;
    private String evalueatedName;
    //getters and setters
}

The model attribute:

public class AssignEvaluationForm{
   private ArrayList<AssigneesViewModel> options;
   public ArrayList<AssigneesViewModel> getOptions() {
      return options;
   }

   public void setOptions(ArrayList<AssigneesViewModel> options) {
      this.options = options;
   }
}

Controller

@RequestMapping(value="addAssignment", method = RequestMethod.GET)
public String addAssignment(Model model){
     model.addAttribute("addAssignment", new AssignEvaluationForm());
     return "addAssignment";
}

Then in the jsp i have 4 hidden inputs which represent the fields for the evaluatedId, evaluatorId, evaluatorName, evaluatedName -> options[0]. How i am going to write the jsp code to map those inputs with an element of the arrayList?

Aucun commentaire:

Enregistrer un commentaire