org.springframework.web.bind.annotation.ModelAttribute Java Examples
The following examples show how to use
org.springframework.web.bind.annotation.ModelAttribute.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TaskWorkspaceController.java From lemon with Apache License 2.0 | 6 votes |
/** * 待办任务. */ @RequestMapping("workspace-personalTasks") public String personalTasks(@ModelAttribute Page page, @RequestParam Map<String, Object> parameterMap, Model model) { String userId = currentUserHolder.getUserId(); String tenantId = tenantHolder.getTenantId(); page = humanTaskConnector.findPersonalTasks(userId, tenantId, page.getPageNo(), page.getPageSize()); // List<PropertyFilter> propertyFilters = PropertyFilter // .buildFromMap(parameterMap); // propertyFilters.add(new PropertyFilter("EQS_status", "active")); // propertyFilters.add(new PropertyFilter("EQS_assignee", userId)); // page = taskInfoManager.pagedQuery(page, propertyFilters); model.addAttribute("page", page); return "humantask/workspace-personalTasks"; }
Example #2
Source File: ExpenseController.java From lemon with Apache License 2.0 | 6 votes |
@RequestMapping("index") public String list(@ModelAttribute Page page, @RequestParam Map<String, Object> parameterMap, Model model) { String tenantId = tenantHolder.getTenantId(); List<PropertyFilter> propertyFilters = PropertyFilter .buildFromMap(parameterMap); propertyFilters.add(new PropertyFilter("EQS_tenantId", tenantId)); page.setDefaultOrder("id", Page.DESC); page = expenseRequestManager.pagedQuery(page, propertyFilters); model.addAttribute("page", page); return "expense/index"; }
Example #3
Source File: PedagogicalPlannerController.java From lams with GNU General Public License v2.0 | 6 votes |
@RequestMapping("/saveOrUpdate") public String saveOrUpdatePedagogicalPlannerForm(@ModelAttribute NbPedagogicalPlannerForm plannerForm, HttpServletRequest request) { MultiValueMap<String, String> errorMap = plannerForm.validate(null); if (errorMap.isEmpty()) { String content = plannerForm.getBasicContent(); Long toolContentID = plannerForm.getToolContentID(); NoticeboardContent noticeboard = nbService.retrieveNoticeboard(toolContentID); noticeboard.setContent(content); nbService.saveNoticeboard(noticeboard); } else { request.setAttribute("errorMap", errorMap); } return "authoring/pedagogicalPlannerForm"; }
Example #4
Source File: WeixinTmessageController.java From jeewx-boot with Apache License 2.0 | 6 votes |
/** * 列表页面 * @return */ @RequestMapping(value="list",method = {RequestMethod.GET,RequestMethod.POST}) public void list(@ModelAttribute WeixinTmessage query,HttpServletResponse response,HttpServletRequest request, @RequestParam(required = false, value = "pageNo", defaultValue = "1") int pageNo, @RequestParam(required = false, value = "pageSize", defaultValue = "10") int pageSize) throws Exception{ String jwid = request.getSession().getAttribute("jwid").toString(); query.setJwid(jwid); PageQuery<WeixinTmessage> pageQuery = new PageQuery<WeixinTmessage>(); pageQuery.setPageNo(pageNo); pageQuery.setPageSize(pageSize); VelocityContext velocityContext = new VelocityContext(); pageQuery.setQuery(query); velocityContext.put("weixinTmessage",query); PageList<WeixinTmessage> pageList = weixinTmessageService.queryPageList(pageQuery); List<WeixinTmessage> tmessgaes = pageList.getValues(); if(tmessgaes != null && tmessgaes.size() > 0) { for (WeixinTmessage tmessgae : tmessgaes) { tmessgae.setExample(tmessgae.getExample().replaceAll("\n", "<br/>")); } } pageList.setValues(tmessgaes); velocityContext.put("pageInfos",SystemTools.convertPaginatedList(pageList)); String viewName = "tmessage/back/weixinTmessage-list.vm"; ViewVelocity.view(request,response,viewName,velocityContext); }
Example #5
Source File: WeixinTmessgaeTaskController.java From jeewx-boot with Apache License 2.0 | 6 votes |
/** * 列表页面 * @return */ @RequestMapping(value="list",method = {RequestMethod.GET,RequestMethod.POST}) public void list(@ModelAttribute WeixinTmessgaeTask query,HttpServletResponse response,HttpServletRequest request, @RequestParam(required = false, value = "pageNo", defaultValue = "1") int pageNo, @RequestParam(required = false, value = "pageSize", defaultValue = "10") int pageSize) throws Exception{ String jwid = request.getSession().getAttribute("jwid").toString(); query.setJwid(jwid); PageQuery<WeixinTmessgaeTask> pageQuery = new PageQuery<WeixinTmessgaeTask>(); pageQuery.setPageNo(pageNo); pageQuery.setPageSize(pageSize); VelocityContext velocityContext = new VelocityContext(); pageQuery.setQuery(query); velocityContext.put("weixinTmessgaeTask",query); velocityContext.put("pageInfos",SystemTools.convertPaginatedList(weixinTmessgaeTaskService.queryPageList(pageQuery))); List<WeixinTmessage> tmessages = weixinTmessageService.queryByJwid(jwid); velocityContext.put("tmessages", tmessages); List<WeixinTag> weixinTags = weixinTagService.getAllTags(jwid); velocityContext.put("weixinTags", weixinTags); String viewName = "tmessage/back/weixinTmessgaeTask-list.vm"; ViewVelocity.view(request,response,viewName,velocityContext); }
Example #6
Source File: LearningController.java From lams with GNU General Public License v2.0 | 6 votes |
@RequestMapping("/openNotebook") public String openNotebook(@ModelAttribute("learningForm") LearningForm learningForm, HttpServletRequest request, HttpServletResponse response) { // set the finished flag PixlrUser pixlrUser = this.getCurrentUser(learningForm.getToolSessionID()); PixlrDTO pixlrDTO = new PixlrDTO(pixlrUser.getPixlrSession().getPixlr()); request.setAttribute("pixlrDTO", pixlrDTO); NotebookEntry notebookEntry = pixlrService.getEntry(pixlrUser.getPixlrSession().getSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL, PixlrConstants.TOOL_SIGNATURE, pixlrUser.getUserId().intValue()); if (notebookEntry != null) { learningForm.setEntryText(notebookEntry.getEntry()); } Long toolSessionID = pixlrUser.getPixlrSession().getSessionId(); request.setAttribute(AttributeNames.ATTR_IS_LAST_ACTIVITY, pixlrService.isLastActivity(toolSessionID)); return "pages/learning/notebook"; }
Example #7
Source File: OrderController.java From spring-in-action-5-samples with Apache License 2.0 | 6 votes |
@GetMapping("/current") public String orderForm(@AuthenticationPrincipal User user, @ModelAttribute Order order) { if (order.getDeliveryName() == null) { order.setDeliveryName(user.getFullname()); } if (order.getDeliveryStreet() == null) { order.setDeliveryStreet(user.getStreet()); } if (order.getDeliveryCity() == null) { order.setDeliveryCity(user.getCity()); } if (order.getDeliveryState() == null) { order.setDeliveryState(user.getState()); } if (order.getDeliveryZip() == null) { order.setDeliveryZip(user.getZip()); } return "orderForm"; }
Example #8
Source File: UserController.java From entando-core with GNU Lesser General Public License v3.0 | 6 votes |
@RestAccessControl(permission = Permission.MANAGE_USERS) @RequestMapping(value = "/{target:.+}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<SimpleRestResponse<UserDto>> updateUser(@ModelAttribute("user") UserDetails user, @PathVariable String target, @Valid @RequestBody UserRequest userRequest, BindingResult bindingResult) { logger.debug("updating user {} with request {}", target, userRequest); //field validations if (bindingResult.hasErrors()) { throw new ValidationGenericException(bindingResult); } this.getUserValidator().validatePutBody(target, userRequest, bindingResult); this.getUserValidator().validateUpdateSelf(target, user.getUsername(), bindingResult); if (bindingResult.hasErrors()) { throw new ValidationGenericException(bindingResult); } UserDto userDto = this.getUserService().updateUser(userRequest); return new ResponseEntity<>(new SimpleRestResponse<>(userDto), HttpStatus.OK); }
Example #9
Source File: TaskController.java From spring4-sandbox with Apache License 2.0 | 6 votes |
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, params = "!action") public String updateTask(@PathVariable("id") Long id, @ModelAttribute("task") @Valid TaskForm fm, BindingResult result, RedirectAttributes redirectAttrs) { log.debug("updating task @" + fm); if (result.hasErrors()) { return "edit"; } Task task = taskRepository.findOne(id); if (task == null) { throw new TaskNotFoundException(id); } task.setName(fm.getName()); task.setDescription(fm.getDescription()); taskRepository.save(task); redirectAttrs.addFlashAttribute("flashMessage", AlertMessage.info("Task is updated sucessfully!")); return "redirect:/tasks"; }
Example #10
Source File: CommentBulkUnapproveController.java From wallride with Apache License 2.0 | 6 votes |
@RequestMapping public String unapprove( @Valid @ModelAttribute("form") CommentBulkUnapproveForm form, BindingResult errors, String query, AuthorizedUser authorizedUser, RedirectAttributes redirectAttributes, Model model) { redirectAttributes.addAttribute("query", query); if (errors.hasErrors()) { logger.debug("Errors: {}", errors); return "redirect:/_admin/{language}/comments/index"; } Collection<Comment> unapprovedComments; try { unapprovedComments = commentService.bulkUnapproveComment(form.toCommentBulkUnapproveRequest(), authorizedUser); } catch (ServiceException e) { return "redirect:/_admin/{language}/comments/index"; } redirectAttributes.addFlashAttribute("unapprovedComments", unapprovedComments); return "redirect:/_admin/{language}/comments/index"; }
Example #11
Source File: LearningController.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Display empty reflection form. */ @RequestMapping("/newReflection") public String newReflection(@ModelAttribute("reflectionForm") ReflectionForm refForm, HttpServletRequest request) { // get session value String sessionMapID = WebUtil.readStrParam(request, AssessmentConstants.ATTR_SESSION_MAP_ID); HttpSession ss = SessionManager.getSession(); UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); refForm.setUserID(user.getUserID()); refForm.setSessionMapID(sessionMapID); // get the existing reflection entry SessionMap<String, Object> sessionMap = getSessionMap(request); Long toolSessionID = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); NotebookEntry entry = service.getEntry(toolSessionID, user.getUserID()); if (entry != null) { refForm.setEntryText(entry.getEntry()); } return "pages/learning/notebook"; }
Example #12
Source File: WeixinAutoresponseController.java From jeewx-boot with Apache License 2.0 | 6 votes |
/** * 保存信息 * @return */ @RequestMapping(value = "/doAdd",method ={RequestMethod.GET, RequestMethod.POST}) @ResponseBody public AjaxJson doAdd(@ModelAttribute WeixinAutoresponse weixinAutoresponse){ AjaxJson j = new AjaxJson(); try { weixinAutoresponse.setCreateTime(new Date()); weixinAutoresponseService.doAdd(weixinAutoresponse); j.setMsg("保存成功"); } catch (Exception e) { log.error(e.getMessage()); j.setSuccess(false); j.setMsg("保存失败"); } return j; }
Example #13
Source File: AdminDepartmentFromController.java From Spring-MVC-Blueprints with MIT License | 6 votes |
@RequestMapping(method=RequestMethod.POST) public RedirectView submitForm(Model model, @Validated @ModelAttribute("deptForm") DepartmentForm deptForm, BindingResult bindingResult){ model.addAttribute("deptForm", deptForm); RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); redirectView.setUrl("/smp/admin_add_department.html"); List<Tbldepartment> depts = reportService.getAllDepartment(); model.addAttribute("depts", depts); if(bindingResult.hasErrors()) { deptForm = new DepartmentForm(); model.addAttribute("deptForm", deptForm); } else{ managementService.addDepartment(deptForm); deptForm = new DepartmentForm(); model.addAttribute("deptForm", deptForm); } return redirectView; }
Example #14
Source File: UserController.java From SOFRepos with MIT License | 6 votes |
@RequestMapping(value = "/user", params = "add", method = RequestMethod.POST) public String postAddUser(@ModelAttribute @Valid User user, BindingResult result, Model model) { System.out.println("result->has errors:-"+result.hasErrors()+" "+result); if (result.hasErrors()) { System.out.println(result.getAllErrors().toString()); ArrayList<Role> roles = new ArrayList<Role>(); roles.add(Role.ADMIN); roles.add(Role.HEAD_OF_DEPARTMENT); model.addAttribute("roles", roles); return "user/add"; } else { System.out.println("Inside postAddUser"); user = userService.save(user); return "redirect:user?id=" + user.getId(); } }
Example #15
Source File: ThemeManagementController.java From lams with GNU General Public License v2.0 | 6 votes |
@RequestMapping(path = "/removeTheme") public String removeTheme(@ModelAttribute ThemeForm themeForm, HttpServletRequest request, HttpServletResponse response) throws Exception { // Remove the theme if (themeForm.getId() != null) { themeService.removeTheme(themeForm.getId()); } String currentTheme = Configuration.get(ConfigurationKeys.DEFAULT_THEME); if (themeForm.getName().equals(currentTheme)) { Configuration.updateItem(ConfigurationKeys.DEFAULT_THEME, CSSThemeUtil.DEFAULT_HTML_THEME); configurationService.persistUpdate(); } themeForm.clear(); return unspecified(themeForm, request); }
Example #16
Source File: UiController.java From spring-boot-admin with Apache License 2.0 | 6 votes |
@ModelAttribute(value = "baseUrl", binding = false) public String getBaseUrl(UriComponentsBuilder uriBuilder) { UriComponents publicComponents = UriComponentsBuilder.fromUriString(this.publicUrl).build(); if (publicComponents.getScheme() != null) { uriBuilder.scheme(publicComponents.getScheme()); } if (publicComponents.getHost() != null) { uriBuilder.host(publicComponents.getHost()); } if (publicComponents.getPort() != -1) { uriBuilder.port(publicComponents.getPort()); } if (publicComponents.getPath() != null) { uriBuilder.path(publicComponents.getPath()); } return uriBuilder.path("/").toUriString(); }
Example #17
Source File: JwSystemUserJwidController.java From jeewx-boot with Apache License 2.0 | 6 votes |
/** * 列表页面 * @return */ @RequestMapping(value="list",method = {RequestMethod.GET,RequestMethod.POST}) public void list(@ModelAttribute JwSystemUserJwid query,HttpServletResponse response,HttpServletRequest request, @RequestParam(required = false, value = "pageNo", defaultValue = "1") int pageNo, @RequestParam(required = false, value = "pageSize", defaultValue = "10") int pageSize) throws Exception{ String userId = query.getUserId(); VelocityContext velocityContext = new VelocityContext(); if(StringUtils.isNotEmpty(userId)){ PageQuery<JwSystemUserJwid> pageQuery = new PageQuery<JwSystemUserJwid>(); pageQuery.setPageNo(pageNo); pageQuery.setPageSize(pageSize); pageQuery.setQuery(query); velocityContext.put("jwSystemUserJwid",query); velocityContext.put("pageInfos",SystemTools.convertPaginatedList(jwSystemUserJwidService.queryPageList(pageQuery))); } String viewName = "system/back/jwSystemUserJwid-list.vm"; ViewVelocity.view(request,response,viewName,velocityContext); }
Example #18
Source File: SetupController.java From wallride with Apache License 2.0 | 5 votes |
@RequestMapping(method = RequestMethod.POST) public String save( @Valid @ModelAttribute("form") SetupForm form, BindingResult result, RedirectAttributes redirectAttributes) { Blog blog = blogService.getBlogById(Blog.DEFAULT_ID); if (blog != null) { throw new HttpForbiddenException(); } if (result.hasErrors()) { return "setup"; } setupService.setup(form.buildSetupRequest()); return "redirect:/_admin/login"; }
Example #19
Source File: OneM2MController.java From SI with BSD 2-Clause "Simplified" License | 5 votes |
@RequestMapping(value="/platform/delete.do") @ResponseBody public Map<String, Object> deletePlatform(@ModelAttribute("platformVO") PlatformVO platformVO) throws Exception { Map<String, Object> dataMap = new HashMap<String, Object>(); dataMap.put("result", true); platformService.deletePlatform(platformVO); return dataMap; }
Example #20
Source File: ServletAnnotationControllerHandlerMethodTests.java From java-technology-stack with MIT License | 5 votes |
@RequestMapping("/myPath.do") public String myHandle(@ModelAttribute("myCommand") TestBean tb, BindingResult errors, ModelMap model) { FieldError error = errors.getFieldError("age"); assertNotNull("Must have field error for age property", error); assertEquals("value2", error.getRejectedValue()); if (!model.containsKey("myKey")) { model.addAttribute("myKey", "myValue"); } return "myView"; }
Example #21
Source File: WeixinTmessageController.java From jeewx-boot with Apache License 2.0 | 5 votes |
/** * 保存信息 * @return */ @RequestMapping(value = "/doAdd",method ={RequestMethod.GET, RequestMethod.POST}) @ResponseBody public AjaxJson doAdd(@ModelAttribute WeixinTmessage weixinTmessage){ AjaxJson j = new AjaxJson(); try { weixinTmessageService.doAdd(weixinTmessage); j.setMsg("保存成功"); } catch (Exception e) { log.error(e.getMessage()); j.setSuccess(false); j.setMsg("保存失败"); } return j; }
Example #22
Source File: ModelAttributeMethodArgumentResolverTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void createAndBindToMono() throws Exception { MethodParameter parameter = this.testMethod .annotNotPresent(ModelAttribute.class).arg(Mono.class, Foo.class); testBindFoo("fooMono", parameter, mono -> { assertTrue(mono.getClass().getName(), mono instanceof Mono); Object value = ((Mono<?>) mono).block(Duration.ofSeconds(5)); assertEquals(Foo.class, value.getClass()); return (Foo) value; }); }
Example #23
Source File: LearningController.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Display empty reflection form. * * @param mapping * @param form * @param request * @param response * @return */ @RequestMapping(value = "/newReflection") private String newReflection(@ModelAttribute("messageForm") ReflectionForm messageForm, HttpServletRequest request) { // get session value String sessionMapID = WebUtil.readStrParam(request, SurveyConstants.ATTR_SESSION_MAP_ID); HttpSession ss = SessionManager.getSession(); UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); messageForm.setUserID(user.getUserID()); messageForm.setSessionMapID(sessionMapID); // get the existing reflection entry SessionMap<String, Object> map = (SessionMap<String, Object>) request.getSession().getAttribute(sessionMapID); Long toolSessionID = (Long) map.get(AttributeNames.PARAM_TOOL_SESSION_ID); NotebookEntry entry = surveyService.getEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL, SurveyConstants.TOOL_SIGNATURE, user.getUserID()); if (entry != null) { messageForm.setEntryText(entry.getEntry()); } request.setAttribute("messageForm", messageForm); return "pages/learning/notebook"; }
Example #24
Source File: WeixinTmessgaeTaskController.java From jeewx-boot with Apache License 2.0 | 5 votes |
/** * 编辑 * @return */ @RequestMapping(value = "/doEdit",method ={RequestMethod.GET, RequestMethod.POST}) @ResponseBody public AjaxJson doEdit(@ModelAttribute WeixinTmessgaeTask weixinTmessgaeTask){ AjaxJson j = new AjaxJson(); try { weixinTmessgaeTaskService.doEdit(weixinTmessgaeTask); j.setMsg("编辑成功"); } catch (Exception e) { log.error(e.getMessage()); j.setSuccess(false); j.setMsg("编辑失败"); } return j; }
Example #25
Source File: CardAvatarController.java From lemon with Apache License 2.0 | 5 votes |
@RequestMapping("card-avatar-list") public String list(@ModelAttribute Page page, @RequestParam Map<String, Object> parameterMap, Model model) { String tenantId = tenantHolder.getTenantId(); List<PropertyFilter> propertyFilters = PropertyFilter .buildFromMap(parameterMap); propertyFilters.add(new PropertyFilter("EQS_tenantId", tenantId)); page = cardAvatarManager.pagedQuery(page, propertyFilters); model.addAttribute("page", page); return "card/card-avatar-list"; }
Example #26
Source File: LogonControllerBasic.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
@Anonymous @GetMapping("/logon/authenticate-host.action") public String hostAuthenticationAskSecurityCode(Logon logon, @ModelAttribute("form") LogonHostAuthenticationForm form, Model model, HttpServletRequest request) { logon.require(LogonState.HOST_AUTHENTICATION_SECURITY_CODE); model.addAttribute("adminMailAddress", getEmailForHostAuthentication(logon.getAdmin())); model.addAttribute("supportMailAddress", configService.getValue(ConfigValue.Mailaddress_Support)); model.addAttribute("layoutdir", logonService.getLayoutDirectory(request.getServerName())); return "logon_host_authentication"; }
Example #27
Source File: PermissionsController.java From MaxKey with Apache License 2.0 | 5 votes |
@ResponseBody @RequestMapping(value={"/querypermissions"}) public List<RolePermissions> querypermissions(@ModelAttribute("rolePermissions") RolePermissions rolePermissions) { _logger.debug("-querypermissions :" + rolePermissions); //have List<RolePermissions> rolePermissionsedList = rolesService.queryRolePermissions( new RolePermissions(rolePermissions.getAppId(),rolePermissions.getRoleId())); return rolePermissionsedList; }
Example #28
Source File: WeixinGroupMessageSendDetailController.java From jeewx-boot with Apache License 2.0 | 5 votes |
/** * 编辑 * @return */ @RequestMapping(value = "/doEdit",method ={RequestMethod.GET, RequestMethod.POST}) @ResponseBody public AjaxJson doEdit(@ModelAttribute WeixinGroupMessageSendDetail weixinGroupMessageSendDetail){ AjaxJson j = new AjaxJson(); try { weixinGroupMessageSendDetailService.doEdit(weixinGroupMessageSendDetail); j.setMsg("编辑成功"); } catch (Exception e) { log.error(e.getMessage()); j.setSuccess(false); j.setMsg("编辑失败"); } return j; }
Example #29
Source File: CasDetailsController.java From MaxKey with Apache License 2.0 | 5 votes |
@RequestMapping(value={"/add"}) public ModelAndView insert(@ModelAttribute("casDetails") AppsCasDetails casDetails) { _logger.debug("-Add :" + casDetails); transform(casDetails); if (casDetailsService.insert(casDetails)&&appsService.insertApp(casDetails)) { new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.success); } else { new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.error); } return WebContext.forward("forwardUpdate/"+casDetails.getId()); }
Example #30
Source File: FavouriteBlogPageController.java From BlogSystem with Apache License 2.0 | 5 votes |
@RequestMapping("/like") public ModelAndView pageLike(HttpServletRequest request, @ModelAttribute @PathVariable String pageOwnerBloggerName) { ModelAndView mv = new ModelAndView(); setCommon(mv, request, pageOwnerBloggerName); mv.addObject("type", "like"); return mv; }