List of usage examples for org.springframework.web.servlet.view RedirectView RedirectView
public RedirectView(String url)
From source file:org.openmrs.web.controller.visit.VisitTypeFormController.java
/** * The onSubmit function receives the form/command object that was modified by the input form * and saves it to the db// ww w.j a va 2s. co m * * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) */ protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); String view = getFormView(); if (Context.isAuthenticated()) { VisitType visitType = (VisitType) obj; VisitService es = Context.getVisitService(); if (request.getParameter("save") != null) { es.saveVisitType(visitType); view = getSuccessView(); httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "VisitType.saved"); } // if the user is retiring out the VisitType else if (request.getParameter("retire") != null) { String retireReason = request.getParameter("retireReason"); if (visitType.getVisitTypeId() != null && !(StringUtils.hasText(retireReason))) { errors.reject("retireReason", "general.retiredReason.empty"); return showForm(request, response, errors); } es.retireVisitType(visitType, retireReason); httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "VisitType.retiredSuccessfully"); view = getSuccessView(); } // if the user is unretiring the VisitType else if (request.getParameter("unretire") != null) { es.unretireVisitType(visitType); httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "VisitType.unretiredSuccessfully"); view = getSuccessView(); } // if the user is purging the visitType else if (request.getParameter("purge") != null) { try { es.purgeVisitType(visitType); httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "VisitType.purgedSuccessfully"); view = getSuccessView(); } catch (DataIntegrityViolationException e) { httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "error.object.inuse.cannot.purge"); view = "visitType.form?visitTypeId=" + visitType.getVisitTypeId(); } catch (APIException e) { httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "error.general: " + e.getLocalizedMessage()); view = "visitType.form?visitTypeId=" + visitType.getVisitTypeId(); } } } return new ModelAndView(new RedirectView(view)); }
From source file:fr.hoteia.qalingo.web.mvc.controller.customer.CustomerAddressController.java
@RequestMapping(value = FoUrls.PERSONAL_ADD_ADDRESS_URL, method = RequestMethod.POST) public ModelAndView submitCustomerAddAddress(final HttpServletRequest request, @Valid @ModelAttribute("customerAddressForm") CustomerAddressForm customerAddressForm, BindingResult result, final Model model) throws Exception { final Market currentMarket = requestUtil.getCurrentMarket(request); final MarketArea currentMarketArea = requestUtil.getCurrentMarketArea(request); if (result.hasErrors()) { return displayCustomerAddAddress(request, model, customerAddressForm); }//from w w w .j ava2 s . c om // Save the new address customer webCommerceService.updateOrSaveAddressCustomer(request, requestUtil.getRequestData(request), currentMarket, currentMarketArea, customerAddressForm); final String urlRedirect = urlService.generateUrl(FoUrls.PERSONAL_ADD_ADDRESS, requestUtil.getRequestData(request)); return new ModelAndView(new RedirectView(urlRedirect)); }
From source file:net.duckling.ddl.web.controller.pan.WopiController.java
@WebLog(method = "PanSSLRedirectView", params = "rid,remotePath") @RequestMapping("/p") public ModelAndView getSSLRedirectView(@RequestParam("remotePath") String remotePath, HttpServletRequest request) throws UnsupportedEncodingException, MeePoException { PanAcl acl = PanAclUtil.getInstance(request); String mode = request.getParameter("mode"); MeePoMeta meta = panService.ls(acl, remotePath, true); String versionStr = request.getParameter("version"); long version = 0; long size = meta.size; if (!StringUtils.isEmpty(versionStr)) { version = Long.parseLong(versionStr); MeePoRevision tv = findTargetRevision(acl, remotePath, version); size = tv.size;/*from ww w .j ava 2s . c o m*/ } String skey = meta.modified + meta.modifiedBy + version; FileInfo info = new FileInfo(skey, meta.name, remotePath, size, acl.getUid(), acl.getUmtToken(), version); cacheService.set(skey, info); String accessToken = encodeStr(acl.getUid() + "#" + acl.getUmtToken()); String url = info.getOwaServerUrl(getOwaServerDomain(), mode, getEncodedCheckFileUrl(skey), accessToken); return new ModelAndView(new RedirectView(url)); }
From source file:fm.last.citrine.web.TaskFormController.java
@Override public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) {/*from w ww. j ava 2s. c o m*/ TaskDTO taskDTO = (TaskDTO) command; Task oldTask = taskManager.get(taskDTO.getTask().getId()); if (request.getParameter(PARAM_DELETE) != null) { // task from web doesn't have parent/child relationships, so retrieve it from db before deleting taskManager.delete(oldTask); } else { Task newTask = taskDTO.getTask(); if (oldTask != null) { newTask.setChildTasks(oldTask.getChildTasks()); } taskManager.save(newTask); } return new ModelAndView(new RedirectView(getSuccessView(taskDTO.getSelectedGroupName()))); }
From source file:org.iwethey.forums.web.user.UserController.java
/** * Toggle binary settings. Requires a request parameter of "toggle" * that contains the name of the property to toggle. *//*from ww w. jav a 2s . com*/ public ModelAndView toggle(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { User user = (User) request.getAttribute(USER_ATTRIBUTE); String propName = RequestUtils.getStringParameter(request, "toggle", null); if (user != null && propName != null && !propName.equals("")) { BeanWrapper wrap = new BeanWrapperImpl(user); Boolean val = (Boolean) wrap.getPropertyValue(propName); wrap.setPropertyValue(propName, new Boolean(!val.booleanValue())); userManager.saveUserAttributes(user); } return new ModelAndView(new RedirectView(request.getHeader("referer"))); }
From source file:ru.org.linux.user.UserFilterController.java
@RequestMapping(value = "/user-filter/ignore-user", method = RequestMethod.POST, params = "add") public ModelAndView listAdd(HttpServletRequest request, @RequestParam String nick) throws Exception { Template tmpl = Template.getTemplate(request); if (!tmpl.isSessionAuthorized()) { throw new AccessViolationException("Not authorized"); }// w w w . j av a 2 s .com User user = tmpl.getCurrentUser(); user.checkAnonymous(); User addUser = userDao.getUser(nick); // Add nick to ignore list if (nick.equals(user.getNick())) { throw new BadInputException("? ? ??"); } Set<Integer> ignoreSet = ignoreListDao.get(user); if (!ignoreSet.contains(addUser.getId())) { ignoreListDao.addUser(user, addUser); } return new ModelAndView(new RedirectView("/user-filter")); }
From source file:org.openmrs.web.controller.visit.VisitAttributeTypeFormController.java
/** * The onSubmit function receives the form/command object that was modified by the input form * and saves it to the db/*from w ww .j a va 2 s . c o m*/ * * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) */ protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); String view = getFormView(); if (Context.isAuthenticated()) { VisitAttributeType visitAttributeType = (VisitAttributeType) obj; VisitService visitService = Context.getVisitService(); if (request.getParameter("save") != null) { visitService.saveVisitAttributeType(visitAttributeType); view = getSuccessView(); httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "VisitAttributeType.saved"); } // if the user is retiring out the VisitAttributeType else if (request.getParameter("retire") != null) { String retireReason = request.getParameter("retireReason"); if (visitAttributeType.getVisitAttributeTypeId() != null && !(StringUtils.hasText(retireReason))) { errors.reject("retireReason", "general.retiredReason.empty"); return showForm(request, response, errors); } visitService.retireVisitAttributeType(visitAttributeType, retireReason); httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "VisitAttributeType.retiredSuccessfully"); view = getSuccessView(); } // if the user is purging the visitAttributeType else if (request.getParameter("purge") != null) { try { visitService.purgeVisitAttributeType(visitAttributeType); httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "VisitAttributeType.purgedSuccessfully"); view = getSuccessView(); } catch (DataIntegrityViolationException e) { httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "error.object.inuse.cannot.purge"); view = "visitAttributeType.form?visitAttributeTypeId=" + visitAttributeType.getVisitAttributeTypeId(); } catch (APIException e) { httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "error.general: " + e.getLocalizedMessage()); view = "visitAttributeType.form?visitAttributeTypeId=" + visitAttributeType.getVisitAttributeTypeId(); } } else if (request.getParameter("unretire") != null) { try { visitService.unretireVisitAttributeType(visitAttributeType); httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "VisitAttributeType.unretiredSuccessfully"); view = getSuccessView(); } catch (APIException e) { httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "error.general: " + e.getLocalizedMessage()); view = "visitAttributeType.form?visitAttributeTypeId=" + visitAttributeType.getVisitAttributeTypeId(); } } } return new ModelAndView(new RedirectView(view)); }
From source file:com.vlives.boss.merchant.controller.MerchantController.java
/*** * ?----//from ww w .j a va 2s . co m * @author unicorn * @param merchant * @param parentId * @param id * @throws Exception */ @RequestMapping(value = "/{id}/selfupdate.htm", method = RequestMethod.PUT) @OperatorLogAnno(OperatorType.TYPE_UPDATE_MERCHANT) public ModelAndView selfUpdate(@ObjectConvertAnno Operator operator, @ModelAttribute Merchant exmerchant, @PathVariable("id") Long id) throws Exception { Merchant merchant = merchantManager.get(id); getMerchantInfo(exmerchant, merchant); merchantManager.update(merchant, operator); return new ModelAndView(new RedirectView("/manager/internal/merchant/index.htm")); }
From source file:org.semispace.google.webapp.GoogledController.java
@RequestMapping("/removeKey.html") public RedirectView removeGoogleKey() { GoogleKey template = new GoogleKey(); space.takeIfExists(template);// ww w . j av a 2s .c o m return new RedirectView("index.html"); }
From source file:org.openmrs.web.controller.report.CohortListController.java
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { String action = request.getParameter("method"); String error = ""; MessageSourceAccessor msa = getMessageSourceAccessor(); String title = msa.getMessage("Cohort.title"); String refByCompSearch = msa.getMessage("Cohort.referencedByACompositePatientSearch"); String couldNotDelete = msa.getMessage("Cohort.couldNotDelete"); HttpSession httpSession = request.getSession(); if ("delete".equals(action)) { String[] toDelete = request.getParameterValues("cohortId"); if (toDelete != null) { ReportObjectService rs = (ReportObjectService) Context.getService(ReportObjectService.class); List<AbstractReportObject> savedSearches = rs .getReportObjectsByType(OpenmrsConstants.REPORT_OBJECT_TYPE_PATIENTSEARCH); for (String s : toDelete) { int compositeTest = 0; for (ReportObject ro : savedSearches) { PatientSearchReportObject psro = (PatientSearchReportObject) ro; if (psro.getPatientSearch().isComposition()) { List<Object> psList = psro.getPatientSearch().getParsedComposition(); for (Object psObj : psList) { if (psObj.getClass().getName().contains("org.openmrs.reporting.PatientSearch")) { PatientSearch psInner = (PatientSearch) psObj; if (psInner.getSavedCohortId() != null) { if (psInner.getSavedCohortId() == Integer.valueOf(Integer.valueOf(s)) .intValue()) { compositeTest = 1; }/*from w w w. j av a2 s . c o m*/ } } } } } if (compositeTest == 0) { String reason = request.getParameter("voidReason"); Cohort cohort = Context.getCohortService().getCohort(Integer.valueOf(s)); Context.getCohortService().voidCohort(cohort, reason); } else { if (!error.equals("")) { error += "<Br>"; } error += couldNotDelete + " " + title + " " + s + ", " + refByCompSearch; } if (!error.equals("")) { httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error); } } return new ModelAndView(new RedirectView(getSuccessView())); } } return showForm(request, response, errors); }