Esempio n. 1
0
  public ModelAndView addSystemIdentifier(HttpServletRequest request, Object cmd, Errors error) {
    Map<String, Boolean> map = new HashMap<String, Boolean>();
    ModelAndView modelAndView = new ModelAndView(getAjaxViewName(request), map);

    ParticipantInputCommand command = (ParticipantInputCommand) cmd;
    List<SystemAssignedIdentifier> list = command.getParticipant().getSystemAssignedIdentifiers();

    // store the new index for the new Identifier
    int size = list.size();
    Integer[] indexes = new Integer[] {size};
    modelAndView.getModel().put("indexes", indexes);

    // store the new Identifier object into the command.participant
    SystemAssignedIdentifier newIdentifier = new SystemAssignedIdentifier();
    command.getParticipant().addIdentifier(newIdentifier);

    return modelAndView;
  }
Esempio n. 2
0
  public ModelAndView removeSystemIdentifier(HttpServletRequest request, Object cmd, Errors error) {
    Map<String, Boolean> map = new HashMap<String, Boolean>();
    ModelAndView modelAndView = new ModelAndView(getAjaxViewName(request), map);

    ParticipantInputCommand command = (ParticipantInputCommand) cmd;
    List<SystemAssignedIdentifier> list = command.getParticipant().getSystemAssignedIdentifiers();
    list.remove(list.get(command.getIndex()));

    // update the array of remainning indexes after deleting
    int size = list.size();
    Integer[] indexes = new Integer[size];
    for (int i = 0; i < size; i++) {
      indexes[i] = i;
    }

    modelAndView.getModel().put("indexes", indexes);
    modelAndView.getModel().put("remove", "remove");
    return modelAndView;
  }