TheRightGuy

Spring

Sep 14th, 2022
622
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.61 KB | None | 0 0
  1. @RequestMapping(value = "/home", method = RequestMethod.GET) public String home(Model model) {
  2.         List<WarehouseItem> clients = clientService.getAllClients();
  3.  
  4.         ComboBoxProperties comboBoxProperties = new ComboBoxProperties();
  5.         List<String> companies = new ArrayList<>();
  6.         List<String[]> products = new ArrayList<>();
  7.  
  8.         for ( Map.Entry<String, String[]> set: comboBoxProperties.getKeyValuesParForCompaniesAndProducts()
  9.                                                                  .entrySet() ) {
  10.             companies.add(set.getKey());
  11.             products.add(set.getValue());
  12.         }
  13.      
  14.         model.addAttribute("myMap", comboBoxProperties.getKeyValuesParForCompaniesAndProducts());
  15.         model.addAttribute("test", comboBoxProperties.getKeyValuesParForCompaniesAndProducts().keySet());
  16.         model.addAttribute("companies", companies);
  17.         model.addAttribute("products", products);
  18.         model.addAttribute("warehouseItems", clients);
  19.         model.addAttribute("warehouseItem", new WarehouseItem());
  20.         return "home";
  21.     }
  22.  
  23.     @RequestMapping(value = "/home", method = RequestMethod.POST)
  24.     public ModelAndView somethingElse(@RequestBody String key, Model model) {
  25.         ComboBoxProperties comboBoxProperties = new ComboBoxProperties();
  26.         ArrayList<String> comp = new ArrayList<>(
  27.                 Arrays.asList(comboBoxProperties.getKeyValuesParForCompaniesAndProducts().get(key)));
  28.         model.addAttribute("comp", comp);
  29.         ModelAndView view = new ModelAndView();
  30.         view.setViewName("home");
  31.  
  32.         return view;
  33.     }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment