@Test public void testSearchHtml() { ExtendedModelMap modelMap = new ExtendedModelMap(); Ninja command = new Ninja(); command.setFirstName("Sasuke"); command.setLastName("Uchiha"); BindingResult bindingResult = new BeanPropertyBindingResult(command, "ninja"); String result = ninjaCrudController.searchHtml(command, bindingResult, modelMap, mockRequest, mockResponse); assertEquals("/base/ninja-codes-crud", result); Object formCommand = modelMap.get("formCommand"); assertNotNull(formCommand); assertEquals(Ninja.class, formCommand.getClass()); assertEquals(command, modelMap.get("searchCommand")); assertEquals("search", modelMap.get("mode")); assertEquals("ot3-search", modelMap.get("search")); assertEquals("ot3-form hide", modelMap.get("form")); assertEquals("ot3-add", modelMap.get("add")); assertEquals("ot3-update", modelMap.get("update")); assertEquals("post", modelMap.get("method")); }
@RequestMapping(method = RequestMethod.GET) public final String searchHtml(@ModelAttribute("searchCommand") T command, BindingResult bindingResult, Model uiModel, HttpServletRequest request, HttpServletResponse response) { uiModel.addAttribute("formCommand", BeanUtils.instantiate(this.entityBeanType)); uiModel.addAttribute("searchCommand", command); if (!request.getParameterMap().isEmpty()) { preSearch(command, bindingResult, uiModel, request, response); SearchResults<T> results = search(command, request); postSearch(command, results, bindingResult, uiModel, request, response); uiModel.addAttribute("results", results); } else { onLoadSearch(command, bindingResult, uiModel, request, response); } uiModel.addAttribute("mode", "search"); uiModel.addAttribute("search", "ot3-search"); uiModel.addAttribute("form", "ot3-form hide"); uiModel.addAttribute("view", "ot3-view hide"); uiModel.addAttribute("add", "ot3-add"); uiModel.addAttribute("update", "ot3-update"); uiModel.addAttribute("method", "post"); return singlePage; }
BaseCrudController implements InitializingBean { @RequestMapping(method = RequestMethod.GET) public final String searchHtml(@ModelAttribute("searchCommand") T command, BindingResult bindingResult, Model uiModel, HttpServletRequest request, HttpServletResponse response) { uiModel.addAttribute("formCommand", BeanUtils.instantiate(this.entityBeanType)); uiModel.addAttribute("searchCommand", command); if (!request.getParameterMap().isEmpty()) { preSearch(command, bindingResult, uiModel, request, response); SearchResults<T> results = search(command, request); postSearch(command, results, bindingResult, uiModel, request, response); uiModel.addAttribute("results", results); } else { onLoadSearch(command, bindingResult, uiModel, request, response); } uiModel.addAttribute("mode", "search"); uiModel.addAttribute("search", "ot3-search"); uiModel.addAttribute("form", "ot3-form hide"); uiModel.addAttribute("view", "ot3-view hide"); uiModel.addAttribute("add", "ot3-add"); uiModel.addAttribute("update", "ot3-update"); uiModel.addAttribute("method", "post"); return singlePage; } }
BaseCrudController implements InitializingBean { @RequestMapping(method = RequestMethod.GET) public final String searchHtml(@ModelAttribute("searchCommand") T command, BindingResult bindingResult, Model uiModel, HttpServletRequest request, HttpServletResponse response) { uiModel.addAttribute("formCommand", BeanUtils.instantiate(this.entityBeanType)); uiModel.addAttribute("searchCommand", command); if (!request.getParameterMap().isEmpty()) { preSearch(command, bindingResult, uiModel, request, response); SearchResults<T> results = search(command, request); postSearch(command, results, bindingResult, uiModel, request, response); uiModel.addAttribute("results", results); } else { onLoadSearch(command, bindingResult, uiModel, request, response); } uiModel.addAttribute("mode", "search"); uiModel.addAttribute("search", "ot3-search"); uiModel.addAttribute("form", "ot3-form hide"); uiModel.addAttribute("view", "ot3-view hide"); uiModel.addAttribute("add", "ot3-add"); uiModel.addAttribute("update", "ot3-update"); uiModel.addAttribute("method", "post"); return singlePage; }  }
BaseCrudController implements InitializingBean { @RequestMapping(method = RequestMethod.GET) public final String searchHtml(@ModelAttribute("searchCommand") T command, BindingResult bindingResult, Model uiModel, HttpServletRequest request, HttpServletResponse response) { uiModel.addAttribute("formCommand", BeanUtils.instantiate(this.entityBeanType)); uiModel.addAttribute("searchCommand", command); if (!request.getParameterMap().isEmpty()) { preSearch(command, bindingResult, uiModel, request, response); SearchResults<T> results = search(command, request); postSearch(command, results, bindingResult, uiModel, request, response); uiModel.addAttribute("results", results); } else { onLoadSearch(command, bindingResult, uiModel, request, response); } uiModel.addAttribute("mode", "search"); uiModel.addAttribute("search", "ot3-search"); uiModel.addAttribute("form", "ot3-form hide"); uiModel.addAttribute("view", "ot3-view hide"); uiModel.addAttribute("add", "ot3-add"); uiModel.addAttribute("update", "ot3-update"); uiModel.addAttribute("method", "post"); return singlePage; }  @ExceptionHandler(Exception.class) @ResponseBody Map<String, Object> handleBindException(Exception ex,
			HttpServletRequest request); @RequestMapping(method = RequestMethod.GET, produces = "application/json") @ResponseView(Views.SearchView.class) final @ResponseBody SearchResults<T> search(@ModelAttribute("searchCommand") T command,
			BindingResult bindingResult, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.GET) final String searchHtml(@ModelAttribute("searchCommand") T command,
			BindingResult bindingResult, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"", "0"}, method = RequestMethod.POST, produces = "application/json") @ResponseView(Views.FormView.class) final @ResponseBody Map<String, Object> create(@FormBind(name = "formCommand") T command,
			BindingResult bindingResult, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = "{id}", method = { RequestMethod.PUT, RequestMethod.POST }, produces = "application/json") @ResponseView(Views.FormView.class) final @ResponseBody Map<String, Object> update(@FormBind(name = "formCommand") T command,
			@PathVariable("id") Long id, BindingResult bindingResult,
			Model uiModel, HttpServletRequest request,
			HttpServletResponse response); @RequestMapping(value = "{id}", method = RequestMethod.GET, produces = "application/json") @ResponseView(Views.FormView.class) final @ResponseBody T get(@PathVariable("id") Long id, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); void preProcessCommand(T command); @RequestMapping(value = "{id}", method = RequestMethod.GET) String getHtml(@PathVariable("id") Long id, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = "/view/{id}", method = RequestMethod.GET) String getDisplayHtml(@PathVariable("id") Long id, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = "{id}", method = RequestMethod.DELETE, produces = "application/json") final @ResponseBody Map<String, Object> delete(@PathVariable("id") Long id, T command,
			BindingResult bindingResult, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @SuppressWarnings({ "unchecked" }) @Override void afterPropertiesSet(); final BaseCrudService<T> getService(); }
BaseCrudController implements InitializingBean { @RequestMapping(method = RequestMethod.GET) public final String searchHtml(@ModelAttribute("searchCommand") T command, BindingResult bindingResult, Model uiModel, HttpServletRequest request, HttpServletResponse response) { uiModel.addAttribute("formCommand", BeanUtils.instantiate(this.entityBeanType)); uiModel.addAttribute("searchCommand", command); if (!request.getParameterMap().isEmpty()) { preSearch(command, bindingResult, uiModel, request, response); SearchResults<T> results = search(command, request); postSearch(command, results, bindingResult, uiModel, request, response); uiModel.addAttribute("results", results); } else { onLoadSearch(command, bindingResult, uiModel, request, response); } uiModel.addAttribute("mode", "search"); uiModel.addAttribute("search", "ot3-search"); uiModel.addAttribute("form", "ot3-form hide"); uiModel.addAttribute("view", "ot3-view hide"); uiModel.addAttribute("add", "ot3-add"); uiModel.addAttribute("update", "ot3-update"); uiModel.addAttribute("method", "post"); return singlePage; }  @ExceptionHandler(Exception.class) @ResponseBody Map<String, Object> handleBindException(Exception ex,
			HttpServletRequest request); @RequestMapping(method = RequestMethod.GET, produces = "application/json") @ResponseView(Views.SearchView.class) final @ResponseBody SearchResults<T> search(@ModelAttribute("searchCommand") T command,
			BindingResult bindingResult, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.GET) final String searchHtml(@ModelAttribute("searchCommand") T command,
			BindingResult bindingResult, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"", "0"}, method = RequestMethod.POST, produces = "application/json") @ResponseView(Views.FormView.class) final @ResponseBody Map<String, Object> create(@FormBind(name = "formCommand") T command,
			BindingResult bindingResult, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = "{id}", method = { RequestMethod.PUT, RequestMethod.POST }, produces = "application/json") @ResponseView(Views.FormView.class) final @ResponseBody Map<String, Object> update(@FormBind(name = "formCommand") T command,
			@PathVariable("id") Long id, BindingResult bindingResult,
			Model uiModel, HttpServletRequest request,
			HttpServletResponse response); @RequestMapping(value = "{id}", method = RequestMethod.GET, produces = "application/json") @ResponseView(Views.FormView.class) final @ResponseBody T get(@PathVariable("id") Long id, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); void preProcessCommand(T command); @RequestMapping(value = "{id}", method = RequestMethod.GET) String getHtml(@PathVariable("id") Long id, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = "/view/{id}", method = RequestMethod.GET) String getDisplayHtml(@PathVariable("id") Long id, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = "{id}", method = RequestMethod.DELETE, produces = "application/json") final @ResponseBody Map<String, Object> delete(@PathVariable("id") Long id, T command,
			BindingResult bindingResult, Model uiModel,
			HttpServletRequest request, HttpServletResponse response); @SuppressWarnings({ "unchecked" }) @Override void afterPropertiesSet(); final BaseCrudService<T> getService();  }