List of usage examples for org.springframework.web.context.request WebRequest getParameter
@Nullable String getParameter(String paramName);
From source file:com.seajas.search.profiler.controller.ArchiveController.java
/** * Render the submit action in the same way as a regular page view is rendered. * //from www . j a v a 2s . c om * @param command * @param result * @param model * @param request * @return String * @throws Exception */ @RequestMapping(method = RequestMethod.POST) public String processSubmit(@ModelAttribute("archiveCommand") final ArchiveCommand command, final BindingResult result, final ModelMap model, final WebRequest request) throws Exception { Collection<String> archiveUrls = new Vector<String>(); if (request.getParameterValues("archiveUrls") != null) for (String archiveUrl : request.getParameterValues("archiveUrls")) archiveUrls.add(archiveUrl); command.setArchiveUrls(archiveUrls); if (request.getParameter("isEnabled") == null) command.setIsEnabled(false); validator.validate(command, result); if (!result.hasErrors()) { if (command.getAction().equals("add")) profilerService.addArchive(command.getName(), command.getDescription(), command.getTransformerContent(), command.getInternalLink(), command.getDeletionExpression(), command.getExclusionExpression(), command.getArchiveUrls(), command.getIsEnabled()); else if (command.getAction().equals("edit")) profilerService.modifyArchive(command.getId(), command.getName(), command.getDescription(), command.getTransformerContent(), command.getInternalLink(), command.getDeletionExpression(), command.getExclusionExpression(), command.getArchiveUrls(), command.getIsEnabled()); else if (command.getAction().equals("delete")) profilerService.deleteArchive(command.getId()); // Re-populate the data model.put("data", populateData()); command.clear(); } return "archives"; }
From source file:com.blackducksoftware.tools.appedit.web.controller.naiaudit.EditNaiAuditDetailsController.java
private ApplicationPojo getApplication(final WebRequest request) throws AppEditControllerException { ApplicationPojo app;//from w ww . j a v a2 s . c o m String appId = request.getParameter("appId"); final String appName = request.getParameter("appName"); logger.debug("appId: " + appId + "; appName: " + appName); if ((appId == null) && (appName == null)) { throw new AppEditControllerException("redirect:/error/400", null); } // Load the app (so we have name, version) if (appId == null) { try { app = vulnNaiAuditDetailsService.getApplicationByNameVersion(appName, config.getAppVersion(), true); } catch (final AppEditException e) { final String msg = "Error loading application " + appName + ": " + e.getMessage(); throw new AppEditControllerException("error/programError", msg); } appId = app.getId(); } else { try { app = vulnNaiAuditDetailsService.getApplicationById(appId, true); } catch (final AppEditException e) { final String msg = "Error loading application with ID " + appId + ": " + e.getMessage(); throw new AppEditControllerException("error/programError", msg); } } logger.info("Application name: " + app.getName()); return app; }
From source file:org.openmrs.module.cohort.web.controller.AddCohortAttributesController.java
@RequestMapping(value = "/module/cohort/addCohortAttributes", method = RequestMethod.GET) public void manage(@RequestParam(required = false, value = "ca") Integer id, WebRequest request, ModelMap model, @ModelAttribute("cohortatt") CohortAttribute cohortattribute) { int a = 0;/* w ww . j a v a 2 s .co m*/ CohortM cohort = null; CohortAttributeType coat = null; CohortService s = Context.getService(CohortService.class); List<CohortAttributeType> att = s.findCohortAttributes(); model.addAttribute("attypes", att); String atype = request.getParameter("cohortAttributeTypeId"); if (StringUtils.hasText(atype)) { a = Integer.parseInt(atype); } List<CohortAttributeType> cat = s.findCohortAttType(a); if (cat.size() > 0) { coat = cat.get(0); } /*if(cohortattribute!=null) { //cohortattribute=new CohortAttribute(); //}*/ List<CohortM> c = s.findCohort(id); if (c.size() > 0) { cohort = c.get(0); } model.addAttribute("cohortmodule", cohort); cohortattribute.setCohort(cohort); cohortattribute.setCohortAttributeType(coat); model.addAttribute("cohortatt", cohortattribute); //} /*model.addAttribute("cohort",c.get(0));*/ model.addAttribute("selectedvalue", request.getParameter("selectedvalue")); }
From source file:org.openmrs.module.cohort.web.controller.AddCohortMemberAttributesController.java
@RequestMapping(value = "/module/cohort/addCohortMemberAttribute", method = RequestMethod.GET) public void manage(@RequestParam(required = false, value = "cma") Integer id, WebRequest request, ModelMap model, @ModelAttribute("cohortatt") CohortMemberAttribute cohortattribute) { int a = 0;/*from w ww.j av a 2s.c om*/ CohortMember cohort = null; CohortMemberAttributeType coat = null; CohortService s = Context.getService(CohortService.class); List<CohortMemberAttributeType> ls = s.findCohortMemberAttributeType(); model.addAttribute("attypes", ls); String atype = request.getParameter("cohortMemberAttributeTypeId"); if (StringUtils.hasText(atype)) { a = Integer.parseInt(atype); } List<CohortMemberAttributeType> cat = s.findCohortMemAttType(a); if (cat.size() > 0) { coat = cat.get(0); } List<CohortMember> c = s.getCohortMember(id); if (c.size() > 0) { cohort = c.get(0); } cohortattribute.setCohortMember(cohort); model.addAttribute("cohortmember", cohort); cohortattribute.setCohortMemberAttributeType(coat); model.addAttribute("cohortatt", cohortattribute); model.addAttribute("selectedvalue", request.getParameter("selectedvalue")); }
From source file:org.openmrs.module.openhmis.inventory.web.controller.JasperReportController.java
private String renderStockCardReport(int reportId, WebRequest request, HttpServletResponse response) throws IOException { int itemId;/*from ww w . j ava 2s .co m*/ String itemName; Date beginDate = null, endDate = null; String temp = request.getParameter("itemUuid"); if (!StringUtils.isEmpty(temp)) { IItemDataService itemService = Context.getService(IItemDataService.class); Item item = itemService.getByUuid(temp); if (item != null) { itemId = item.getId(); itemName = item.getName(); } else { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "No item with UUID '" + temp + "' could be found."); return null; } } else { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "The item uuid must be defined."); return null; } SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy"); temp = request.getParameter("beginDate"); if (!StringUtils.isEmpty(temp)) { try { beginDate = dateFormat.parse(temp); } catch (Exception ex) { // Whatevs... dealing with stupid checked exceptions } } temp = request.getParameter("endDate"); if (!StringUtils.isEmpty(temp)) { try { endDate = dateFormat.parse(temp); } catch (Exception ex) { // Whatevs... dealing with stupid checked exceptions } } if (beginDate == null || endDate == null) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "The begin and end dates must be defined."); return null; } HashMap<String, Object> params = new HashMap<String, Object>(); params.put("itemId", itemId); params.put("beginDate", beginDate); params.put("endDate", endDate); return renderReport(reportId, params, "Item Stock Card - " + itemName, response); }
From source file:org.openmrs.module.openhmis.inventory.web.controller.JasperReportController.java
private String renderStockOperationsByStockroomReport(int reportId, WebRequest request, HttpServletResponse response) throws IOException { int itemId;// w ww .j av a 2s. c o m Date beginDate = null, endDate = null; int stockroomId; String temp = request.getParameter("stockroomId"); if (!StringUtils.isEmpty(temp) && StringUtils.isNumeric(temp)) { stockroomId = Integer.parseInt(temp); } else { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "The stockroom id ('" + temp + "') must be " + "defined and be numeric."); return null; } temp = request.getParameter("itemUuid"); if (!StringUtils.isEmpty(temp)) { IItemDataService itemService = Context.getService(IItemDataService.class); Item item = itemService.getByUuid(temp); if (item != null) { itemId = item.getId(); } else { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "No item with UUID '" + temp + "' could be found."); return null; } } else { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "The item uuid must be defined."); return null; } SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy"); temp = request.getParameter("beginDate"); if (!StringUtils.isEmpty(temp)) { try { beginDate = dateFormat.parse(temp); } catch (Exception ex) { // Whatevs... dealing with stupid checked exceptions } } temp = request.getParameter("endDate"); if (!StringUtils.isEmpty(temp)) { try { endDate = dateFormat.parse(temp); } catch (Exception ex) { // Whatevs... dealing with stupid checked exceptions } } if (beginDate == null || endDate == null) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "The begin and end dates must be defined."); return null; } HashMap<String, Object> params = new HashMap<String, Object>(); params.put("itemId", itemId); params.put("beginDate", beginDate); params.put("endDate", endDate); params.put("stockroomId", stockroomId); return renderReport(reportId, params, null, response); }
From source file:cz.strmik.cmmitool.web.controller.EvidenceController.java
@RequestMapping(method = RequestMethod.POST, value = "/characterize.do") public String characterizeEvidenceSave(@ModelAttribute(Attribute.PROJECT) Project project, ModelMap modelMap, HttpSession session, WebRequest request) { project = projectDao.read(project.getId()); checkIsAudior(project);//from ww w .j a va2 s . co m Iterator<String> it = request.getParameterNames(); while (it.hasNext()) { String param = it.next(); String value = request.getParameter(param); if (log.isDebugEnabled()) { log.debug("Read parameter: " + param + " = " + value); } if (param.matches("^practice-char-\\d+?-\\d+$")) { setPracticeChar(param, value, project); } else if (param.matches("^practice-adequacy-\\d+?-\\d+$")) { setPracticeAdequacy(param, value, project); } else if (param.matches("^evidence-char-\\d+#\\d+#\\d+$")) { setEvidenceChar(param, value, project); } else if (param.matches("^evidence-ind-\\d+#\\d+#\\d+$")) { setEvidenceInd(param, value, project); } else { log.debug("skipping parameter " + param); } } projectDao.update(project); return "redirect:/appraisal/evidence/"; }
From source file:org.openmrs.module.cohort.web.controller.AddCohortMemberAttributesController.java
@RequestMapping(value = "/module/cohort/addCohortMemberAttribute.form", method = RequestMethod.POST) public ModelAndView onSubmit(WebRequest request, HttpSession httpSession, ModelMap model, @RequestParam(required = false, value = "cohortMemberAttributeTypeId") Integer cohort_attribute_type, @RequestParam(required = false, value = "selectedvalue") String description, @ModelAttribute("cohortatt") CohortMemberAttribute cohortattributes, BindingResult errors) { CohortService departmentService = Context.getService(CohortService.class); CohortMemberAttributeType a = null;// w ww .j ava 2 s. c o m Integer id = Integer.parseInt(request.getParameter("cma")); List<CohortMember> cohort1 = departmentService.getCohortMember(id); if (description == "") { httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "Values cannot be null"); } else { List<CohortMemberAttributeType> att = departmentService.findCohortMemAttType(cohort_attribute_type); for (int i = 0; i < att.size(); i++) { a = att.get(i); } cohortattributes.setCohortMember(cohort1.get(0)); cohortattributes.setCohortMemberAttributeType(a); departmentService.saveCohortMemberAttribute(cohortattributes); model.addAttribute("attypes", att); model.addAttribute("cohortatt", cohortattributes); httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "insertion success"); } return null; }