Exemplo n.º 1
0
 @RequestMapping(method = RequestMethod.GET)
 public Searcher handleRequest(HttpServletRequest request, HttpServletResponse response) {
   this.office = request.getParameter("office");
   Searcher searcher = new Searcher();
   searcher.setId("Enter client NIF");
   return searcher;
 }
Exemplo n.º 2
0
  @RequestMapping(method = RequestMethod.POST)
  public ModelAndView submit(@Valid Searcher searcher, BindingResult result) {
    String id = searcher.getId();

    if (id.equals("") || id.isEmpty()) {
      Map<String, Object> map = new HashMap<String, Object>();
      map.put("clients", this.clientManager.getClients(office));

      return new ModelAndView("clientlist", "model", map);
    } else {
      Person person = (Person) this.clientManager.searchClient(id);

      if (person != null) {
        Map<String, Object> model = new HashMap<String, Object>();
        model.put("client", person);
        return new ModelAndView("client", "model", model);
      } else {
        Map<String, Object> model = new HashMap<String, Object>();
        model.put("clients", this.clientManager.getClients(office));
        return new ModelAndView("clientlist", "model", model);
      }
    }
  }