List of usage examples for org.springframework.web.servlet.view RedirectView RedirectView
public RedirectView(String url)
From source file:org.iwethey.forums.web.post.PostController.java
/** * Expand all history entries.//from w w w . j a v a 2 s . c o m * <p> */ public ModelAndView expandAllHistory(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int id = RequestUtils.getRequiredIntParameter(request, "postid"); Post post = getPostManager().getPostById(id); List entries = post.getEditHistory(); if (entries != null) { ExpandedHistory expanded = ExpandedHistory.getExpandedHistory(request); for (int index = 0; index < entries.size(); index++) { expanded.expand(post, index); } } return new ModelAndView(new RedirectView(request.getHeader("referer"))); }
From source file:org.openmrs.module.validation.web.controller.ValidationController.java
@RequestMapping(value = "/module/validation/validate", method = RequestMethod.POST) public ModelAndView validate(@RequestParam("type") String type, @RequestParam(value = "first", required = false) Long first, @RequestParam(value = "last", required = false) Long last) { try {// www . ja va2s . c o m getValidationService().startNewValidationThread(type, first, last); } catch (Exception e) { log.error("Unable to start validation", e); } return new ModelAndView(new RedirectView("list.form")); }
From source file:ru.org.linux.tracker.TrackerController.java
@RequestMapping("/tracker.jsp") public View trackerOldUrl(@RequestParam(value = "filter", defaultValue = "all") String filterAction) throws UnsupportedEncodingException { RedirectView redirectView = new RedirectView("/tracker/"); redirectView.setExposeModelAttributes(false); if (filterValues.contains(filterAction) && !filterAction.equals("all")) { redirectView.setUrl("/tracker/?filter=" + URLEncoder.encode(filterAction, "UTF-8")); }/*from w ww . j ava2 s . c o m*/ return redirectView; }
From source file:fr.hoteia.qalingo.web.mvc.controller.catalog.AssetController.java
@RequestMapping(value = "/asset-details.html*", method = RequestMethod.GET) public ModelAndView assetDetails(final HttpServletRequest request, final HttpServletResponse response) throws Exception { ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request), BoPageConstants.ASSET_DETAILS_VELOCITY_PAGE); final String currentAssetCode = request.getParameter(RequestConstants.REQUEST_PARAMETER_ASSET_CODE); final Asset asset = productMarketingService.getProductMarketingAssetByCode(currentAssetCode); if (asset != null) { initRuleDetailsPage(request, response, modelAndView, asset); } else {//from ww w . jav a2 s. c om final String url = requestUtil.getLastRequestUrl(request); return new ModelAndView(new RedirectView(url)); } return modelAndView; }
From source file:controller.services.java
@Override protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { //System.out.println("test"); Session s = HibernateUtil.getSessionFactory().getCurrentSession(); s.beginTransaction();/*from ww w.j a v a 2 s .c om*/ ModelAndView mav = new ModelAndView("services"); dummy login = (dummy) command; if ((login.getl3() == null) && (login.gets6().equals("doctor"))) { // if(login.gets6().equals("doctor")){ Logintable l = new Logintable(); l.setCnic(login.getl1()); long j = login.getl1(); int k = (int) j; // long contact = login.getl6(); // int cont = (int) contact; l.setPassword(login.gets2()); l.setStatus(login.gets6()); Doctors doc = new Doctors(); doc.setId(k); doc.setDoctorname(login.gets1()); doc.setDoctordepartment(login.gets5()); //doc.setContact(login.getl6()); doc.setEmail(login.gets7()); doc.setCity(login.gets3()); doc.setAddress(login.gets4()); long z = login.getl2(); int v = (int) z; doc.setPmdcId(v); // Session s = HibernateUtil.getSessionFactory().getCurrentSession(); // s.beginTransaction(); s.save(l); s.save(doc); s.getTransaction().commit(); return new ModelAndView(new RedirectView("home.htm")); } if ((login.getl3() == null) && (login.gets6().equals("patient"))) { // Session session2 = HibernateUtil.getSessionFactory().getCurrentSession(); //session2.beginTransaction(); Logintable pat = new Logintable(); pat.setCnic(login.getl8()); long j = login.getl11(); int k = (int) j; pat.setPassword(login.gets9()); pat.setStatus(login.gets6()); pat.setStatus("Patient"); Patients p = new Patients(); p.setPid(login.getl8()); p.setName(login.gets8()); p.setEmail(login.gets14()); p.setAddress(login.gets12()); p.setAge(k); p.setPhoneNumber(login.getl9()); // p.getPhoneNumber(login.); p.setEmergencyContact(login.getl10()); p.setBloodGroup(login.gets13()); s.save(pat); s.save(p); s.getTransaction().commit(); return new ModelAndView(new RedirectView("home.htm")); } //mv.addObject("photoCommand", photoCommand); if (login.getl3() != null) { Logintable x = new Logintable(); long cnic = login.getl3(); String password = login.gets7(); // Session session3 = HibernateUtil.getSessionFactory().getCurrentSession(); // session3.beginTransaction(); // session3.save(); Query query1 = s.createQuery("from Logintable where cnic = :cnic and password = :password"); query1.setParameter("cnic", cnic); query1.setParameter("password", password); // HttpSession session = request.getSession(); //session.setAttribute("scard", password); //session3.setAttribute("check", "hello beother"); // query1.setParameter("password", password); List list = query1.list(); s.getTransaction().commit(); // String check = list.get(0).toString(); if ((list.size() == 0)) { return new ModelAndView(new RedirectView("signin.htm")); } else { request.getSession().setAttribute("scard", "hello"); return new ModelAndView(new RedirectView("home.htm")); } // session3.getTransaction().commit(); // session3. } //session.close(); //return (mav); return new ModelAndView(new RedirectView("home.htm")); }
From source file:psiprobe.controllers.deploy.UndeployContextController.java
@Override protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request, HttpServletResponse response) throws Exception { try {//www .ja v a2 s . c o m if (request.getContextPath().equals(contextName)) { throw new IllegalStateException( getMessageSourceAccessor().getMessage("probe.src.contextAction.cannotActOnSelf")); } getContainerWrapper().getTomcatContainer().remove(contextName); // Logging action Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); // get username logger logger.info(getMessageSourceAccessor().getMessage("probe.src.log.undeploy"), name, contextName); } catch (Exception e) { request.setAttribute("errorMessage", e.getMessage()); logger.error("Error during undeploy of '{}'", contextName, e); return new ModelAndView( new InternalResourceView(getFailureViewName() == null ? getViewName() : getFailureViewName())); } return new ModelAndView(new RedirectView(request.getContextPath() + getViewName())); }
From source file:org.openmrs.module.sync.web.controller.ConfigListController.java
@Override protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { log.debug("in onSubmit"); ModelAndView result = new ModelAndView(new RedirectView(getSuccessView())); if (!Context.isAuthenticated()) throw new APIAuthenticationException("Not authenticated!"); HttpSession httpSession = request.getSession(); String success = ""; String error = ""; MessageSourceAccessor msa = getMessageSourceAccessor(); String action = ServletRequestUtils.getStringParameter(request, "action", ""); log.debug("action is " + action); if ("deleteServer".equals(action)) { // check to see if the user is trying to delete a server, react accordingly Integer serverId = ServletRequestUtils.getIntParameter(request, "serverId", 0); String serverName = "Server " + serverId.toString(); SyncService ss = Context.getService(SyncService.class); if (serverId > 0) { RemoteServer deleteServer = ss.getRemoteServer(serverId); serverName = deleteServer.getNickname(); try { ss.deleteRemoteServer(deleteServer); Object[] args = { serverName }; success = msa.getMessage("sync.config.server.deleted", args); } catch (Exception e) { Object[] args = { serverName }; error = msa.getMessage("sync.config.server.deleteFailed", args); }/*from w w w.j a v a 2s. c om*/ } else { error = msa.getMessage("sync.config.server.notDeleted"); } } else if ("manualTx".equals(action)) { try { Integer serverId = ServletRequestUtils.getIntParameter(request, "serverId", 0); RemoteServer server = Context.getService(SyncService.class).getRemoteServer(serverId); log.warn("IN MANUAL-TX WITH SERVERID: " + serverId); // we are creating a sync-transmission, so start by generating a SyncTransmission object SyncTransmission tx = SyncUtilTransmission.createSyncTransmission(server, true, SyncUtil.getGlobalPropetyValueAsInteger(SyncConstants.PROPERTY_NAME_MAX_RECORDS_FILE)); String toTransmit = tx.getFileOutput(); // Record last attempt server.setLastSync(new Date()); Context.getService(SyncService.class).saveRemoteServer(server); // Write sync transmission to response InputStream in = new ByteArrayInputStream(toTransmit.getBytes()); response.setContentType("text/xml; charset=utf-8"); response.setHeader("Content-Disposition", "attachment; filename=" + tx.getFileName() + ".xml"); OutputStream out = response.getOutputStream(); IOUtils.copy(in, out); out.flush(); out.close(); // don't return a model/view - we'll need to return a file instead. result = null; } catch (Exception e) { error = msa.getMessage("sync.status.createTx.error"); e.printStackTrace(); } } if (!success.equals("")) httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success); if (!error.equals("")) httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error); return result; }
From source file:controller.contact_us.java
@Override protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { //System.out.println("test"); Session s = HibernateUtil.getSessionFactory().getCurrentSession(); s.beginTransaction();/*from w w w . j a v a 2s . c om*/ ModelAndView mav = new ModelAndView("contact_us"); dummy login = (dummy) command; if ((login.getl3() == null) && (login.gets6().equals("doctor"))) { // if(login.gets6().equals("doctor")){ Logintable l = new Logintable(); l.setCnic(login.getl1()); long j = login.getl1(); int k = (int) j; // long contact = login.getl6(); // int cont = (int) contact; l.setPassword(login.gets2()); l.setStatus(login.gets6()); Doctors doc = new Doctors(); doc.setId(k); doc.setDoctorname(login.gets1()); doc.setDoctordepartment(login.gets5()); //doc.setContact(login.getl6()); doc.setEmail(login.gets7()); doc.setCity(login.gets3()); doc.setAddress(login.gets4()); long z = login.getl2(); int v = (int) z; doc.setPmdcId(v); // Session s = HibernateUtil.getSessionFactory().getCurrentSession(); // s.beginTransaction(); s.save(l); s.save(doc); s.getTransaction().commit(); return new ModelAndView(new RedirectView("home.htm")); } if ((login.getl3() == null) && (login.gets6().equals("patient"))) { // Session session2 = HibernateUtil.getSessionFactory().getCurrentSession(); //session2.beginTransaction(); Logintable pat = new Logintable(); pat.setCnic(login.getl8()); long j = login.getl11(); int k = (int) j; pat.setPassword(login.gets9()); pat.setStatus(login.gets6()); pat.setStatus("Patient"); Patients p = new Patients(); p.setPid(login.getl8()); p.setName(login.gets8()); p.setEmail(login.gets14()); p.setAddress(login.gets12()); p.setAge(k); p.setPhoneNumber(login.getl9()); // p.getPhoneNumber(login.); p.setEmergencyContact(login.getl10()); p.setBloodGroup(login.gets13()); s.save(pat); s.save(p); s.getTransaction().commit(); return new ModelAndView(new RedirectView("home.htm")); } //mv.addObject("photoCommand", photoCommand); if (login.getl3() != null) { Logintable x = new Logintable(); long cnic = login.getl3(); String password = login.gets7(); // Session session3 = HibernateUtil.getSessionFactory().getCurrentSession(); // session3.beginTransaction(); // session3.save(); Query query1 = s.createQuery("from Logintable where cnic = :cnic and password = :password"); query1.setParameter("cnic", cnic); query1.setParameter("password", password); // HttpSession session = request.getSession(); //session.setAttribute("scard", password); //session3.setAttribute("check", "hello beother"); // query1.setParameter("password", password); List list = query1.list(); s.getTransaction().commit(); // String check = list.get(0).toString(); if ((list.size() == 0)) { return new ModelAndView(new RedirectView("signin.htm")); } else { request.getSession().setAttribute("scard", "hello"); return new ModelAndView(new RedirectView("home.htm")); } // session3.getTransaction().commit(); // session3. } //session.close(); //return (mav); return new ModelAndView(new RedirectView("home.htm")); }
From source file:ru.org.linux.user.EditRemarkController.java
@RequestMapping(method = RequestMethod.POST) public ModelAndView editProfile(ServletRequest request, @RequestParam("text") String text, @PathVariable String nick) throws Exception { Template tmpl = Template.getTemplate(request); if (!tmpl.isSessionAuthorized()) { throw new AccessViolationException("Not authorized"); }//www . j a v a 2 s .c o m if (text.length() > 255) { text = text.substring(0, 255); } User user = tmpl.getCurrentUser(); User refUser = userDao.getUser(nick); Remark rm = userDao.getRemark(user, refUser); if (rm != null) { userDao.updateRemark(rm.getId(), text); } else { userDao.setRemark(user, refUser, text); } return new ModelAndView(new RedirectView("/people/" + nick + "/profile")); }
From source file:vn.edu.vnuk.tasks.controller.TasksController.java
@RequestMapping(value = "deleteTask/{id}", method = RequestMethod.GET) @ResponseBody/*ww w .ja v a2 s.c o m*/ public RedirectView delete(@PathVariable("id") int id) throws SQLException { new TaskDao().delete(id); return new RedirectView("../tasks"); }