Ejemplo n.º 1
0
  @ModelAttribute("fullContactList")
  public Set<Map.Entry<Integer, String>> fullContactList() {
    Set<Map.Entry<Integer, String>> contacts;
    Map<Integer, String> selectItems = new HashMap<>();
    List<Person> jdbcContacts = personService.listPeople();
    for (Person contact : jdbcContacts) {
      selectItems.put(contact.getPersonId(), contact.getFirstName() + " " + contact.getLastName());
    }

    contacts = selectItems.entrySet();
    return contacts;
  }
Ejemplo n.º 2
0
  @ModelAttribute("contactList")
  public Set<Map.Entry<Integer, String>> contactList(Client client) {
    Set<Map.Entry<Integer, String>> contacts;
    Map<Integer, String> selectItems = new HashMap<>();
    List<Person> jdbcContacts = personService.listPeople();

    if (client.getContacts() != null) {
      String[] contactIds = client.getContacts().split(",");
      for (Person contact : jdbcContacts) {
        if (Arrays.asList(contactIds).contains(contact.getPersonId().toString())) {
          selectItems.put(
              contact.getPersonId(), contact.getFirstName() + " " + contact.getLastName());
        }
      }
    }
    contacts = selectItems.entrySet();
    return contacts;
  }