Revize b66f682e
Přidáno uživatelem Michal Linha před asi 4 roky(ů)
src/main/java/vldc/aswi/web/controller/AssemblyController.java | ||
---|---|---|
10 | 10 |
import org.springframework.web.servlet.ModelAndView; |
11 | 11 |
import org.springframework.web.servlet.mvc.support.RedirectAttributes; |
12 | 12 |
import vldc.aswi.domain.Assembly; |
13 |
import vldc.aswi.domain.Configuration; |
|
13 | 14 |
import vldc.aswi.service.AssemblyManager; |
15 |
import vldc.aswi.service.ConfigurationManager; |
|
14 | 16 |
import vldc.aswi.service.SqlQueryManager; |
15 | 17 |
|
16 | 18 |
import javax.validation.Valid; |
... | ... | |
24 | 26 |
@Autowired |
25 | 27 |
private AssemblyManager assemblyManager; |
26 | 28 |
|
29 |
@Autowired |
|
30 |
private ConfigurationManager configurationManager; |
|
31 |
|
|
27 | 32 |
@GetMapping("/assembly") |
28 | 33 |
public ModelAndView assemblyIndex(@Valid @ModelAttribute("assemblyID") String id) { |
29 | 34 |
ModelAndView modelAndView = new ModelAndView("assembly"); |
... | ... | |
32 | 37 |
|
33 | 38 |
Assembly assembly = assemblyManager.getAssemblyById(Long.parseLong(id)); |
34 | 39 |
|
35 |
modelMap.addAttribute("assemblies", assemblyManager.getAssemblies()); |
|
36 |
modelMap.addAttribute("assembly", assembly); |
|
40 |
Configuration configuration = new Configuration(); |
|
41 |
|
|
42 |
configuration.setAssembly(assembly); |
|
43 |
|
|
44 |
modelMap.addAttribute("configuration", configuration); |
|
45 |
modelMap.addAttribute("assemblyID", id); |
|
37 | 46 |
|
38 | 47 |
return modelAndView; |
39 | 48 |
} |
40 | 49 |
|
50 |
@GetMapping("/assembly") |
|
51 |
public ModelAndView configurationIndex(@Valid @ModelAttribute("assemblyID") String id) { |
|
52 |
ModelAndView modelAndView = new ModelAndView("assembly"); |
|
53 |
|
|
54 |
ModelMap modelMap = modelAndView.getModelMap(); |
|
55 |
|
|
56 |
Configuration configuration = configurationManager.getConfigurationById(Long.parseLong(id)); |
|
57 |
|
|
58 |
modelMap.addAttribute("configuration", configuration); |
|
59 |
modelMap.addAttribute("assemblyID", configuration.getAssembly().getId()); |
|
60 |
|
|
61 |
return modelAndView; |
|
62 |
} |
|
41 | 63 |
|
42 | 64 |
@PostMapping("/assembly") |
43 | 65 |
public ModelAndView indexPost(@Valid Assembly assembly, BindingResult bindingResult, RedirectAttributes atts) { |
Také k dispozici: Unified diff
re #7881 loading of attributes of assembly on main page