Example usage for org.springframework.web.servlet.view RedirectView RedirectView

List of usage examples for org.springframework.web.servlet.view RedirectView RedirectView

Introduction

In this page you can find the example usage for org.springframework.web.servlet.view RedirectView RedirectView.

Prototype

public RedirectView(String url) 

Source Link

Document

Create a new RedirectView with the given URL.

Usage

From source file:org.openmrs.module.patientnarratives.web.controller.MultiFileUploadController.java

@RequestMapping(FORM_PATH)
public ModelAndView handleRequest(HttpServletRequest request) throws Exception {

    if (request instanceof MultipartHttpServletRequest) {
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        List<MultipartFile> uploadedFiles = multipartRequest.getFiles("files[]");

        try {/*  w w w  .  ja  v a 2s  .c o  m*/
            Iterator<MultipartFile> iterator = uploadedFiles.iterator();
            while (iterator.hasNext()) {
                MultipartFile multipartFile = iterator.next();
                tempFile = multipartToFile(multipartFile);
                saveAndTransferFileComplexObs();
            }
        } catch (Exception e) {
            log.error(e);
            e.getStackTrace();
        }
    }

    returnUrl = request.getContextPath() + "/module/patientnarratives/patientNarrativesForm.form";
    return new ModelAndView(new RedirectView(returnUrl));
}

From source file:controller.about.java

@Override
protected ModelAndView onSubmit(Object command) throws Exception {
    //System.out.println("test");

    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();// ww  w .j a  v a2 s.c om

    ModelAndView mav = new ModelAndView("about");
    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 session = HibernateUtil.getSessionFactory().getCurrentSession();
        // session.beginTransaction();
        session.save(l);
        session.save(doc);

        session.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());

        session.save(pat);

        session.save(p);

        session.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 = session.createQuery("from Logintable where cnic = :cnic and password = :password");
        query1.setParameter("cnic", cnic);
        query1.setParameter("password", password);
        //session3.setAttribute("check", "hello beother");
        // query1.setParameter("password", password);
        List list = query1.list();
        session.getTransaction().commit();
        // String check =  list.get(0).toString();
        if ((list.size() == 0)) {
            return new ModelAndView(new RedirectView("signin.htm"));

        } else {

            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:net.mindengine.oculus.frontend.web.controllers.report.ReportBrowseRememberSelectedRunsController.java

@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Session session = Session.create(request);
    String redirect = request.getParameter("redirect");
    if (redirect == null) {
        redirect = "";
    }/*from   w  ww .j  a  va2 s.c  om*/
    String reqIds = request.getParameter("ids");
    if (reqIds != null && !reqIds.isEmpty()) {
        String[] ids = reqIds.split(",");
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 0; i < ids.length; i++) {
            list.add(Integer.parseInt(ids[i]));
        }
        collectTestRuns(request, list, session);
    }

    String removeIds = request.getParameter("removeIds");
    if (removeIds != null && !removeIds.isEmpty()) {
        removeCollectedTestRuns(removeIds, session);
    }

    return new ModelAndView(new RedirectView(redirect));
}

From source file:net.indialend.attendance.controller.HolidayController.java

@RequestMapping("/delete")
public ModelAndView deleteHoliday(String holidayId) {

    ModelAndView view = new ModelAndView(new RedirectView("list"));
    if (holidayId != null) {

        String[] bids = holidayId.split(",");
        for (String bid : bids) {

            holidayService.deleteHoliday(Long.valueOf(bid));
        }//w ww .  j ava  2  s  . c  o  m

    }

    return view;
}

From source file:com.microservice.training.hal.HalBrowser.java

/**
 * Returns the View to redirect to to access the HAL browser.
 * // w ww  . ja va  2 s  .  com
 * @param request must not be {@literal null}.
 * @param browserRelative
 * @return
 */
private View getRedirectView(HttpServletRequest request, boolean browserRelative) {

    ServletUriComponentsBuilder builder = ServletUriComponentsBuilder.fromRequest(request);

    UriComponents components = builder.build();
    String path = components.getPath() == null ? "" : components.getPath();

    if (!browserRelative) {
        builder.path(BROWSER);
    }

    builder.path(INDEX);
    builder.fragment(browserRelative ? path.substring(0, path.lastIndexOf("/browser")) : path);

    return new RedirectView(builder.build().toUriString());
}

From source file:net.duckling.ddl.web.controller.regist.InvitationValidateController.java

private ModelAndView joinTeamSuccess() {
    String switchTeamURL = urlGenerator.getURL(UrlPatterns.SWITCH_TEAM, "", null);
    ModelAndView mv = new ModelAndView(new RedirectView(switchTeamURL));
    return mv;//from  ww  w .  j  a  v  a 2s  .c  o m
}

From source file:net.sourceforge.subsonic.controller.SetMediaFileController.java

protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    Integer id = ServletRequestUtils.getIntParameter(request, "id");
    String action = request.getParameter("action");
    String strmediaType = request.getParameter("mediatype");

    MediaType mediaType = null;//from  w w w.  ja  va2  s .c  om
    MediaFile mediaFile = mediaFileService.getMediaFile(id);

    if ("setmediatype".equals(action)) {

        if ("MULTIARTIST".equals(strmediaType)) {
            mediaType = MediaType.MULTIARTIST;
        }
        if ("ARTIST".equals(strmediaType)) {
            mediaType = MediaType.ARTIST;
        }
        if ("ALBUMSET".equals(strmediaType)) {
            mediaType = MediaType.ALBUMSET;
        }
        if ("ALBUM".equals(strmediaType)) {
            mediaType = MediaType.ALBUM;
        }
        if ("DIRECTORY".equals(strmediaType)) {
            mediaType = MediaType.DIRECTORY;
        }

        if ("AUTO".equals(strmediaType)) {
            mediaFile.setMediaTypeOverride(false);
        } else {
            mediaFile.setMediaType(mediaType);
            mediaFile.setMediaTypeOverride(true);
        }
        mediaFileService.updateMediaFile(mediaFile);
    }

    String url = "main.view?id=" + id;
    return new ModelAndView(new RedirectView(url));
}

From source file:net.mindengine.oculus.frontend.web.controllers.test.TestDeleteController.java

@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    verifyPermissions(request);/*from   www  . ja  va 2  s.  c o m*/
    Long testId = Long.parseLong(request.getParameter("id"));

    Test test = testDAO.getTest(testId);
    Project project = projectDAO.getProject(test.getProjectId());

    testDAO.delete(testId, project.getId());

    Long rootId = projectDAO.getProjectRootId(test.getProjectId(), 10);
    List<Customization> customizations = customizationDAO.getCustomizations(rootId, Customization.UNIT_TEST);
    customizationDAO.removeAllUnitCustomizationValues(test.getId(), customizations);

    Session session = Session.create(request);
    session.setTemporaryMessage("Test \"" + test.getName() + "\" was removed successfully");

    return new ModelAndView(new RedirectView("../project/display-" + project.getPath()));
}

From source file:jetbrains.buildServer.torrent.web.TorrentSettingsAdminPage.java

public TorrentSettingsAdminPage(@NotNull PagePlaces pagePlaces, @NotNull WebControllerManager controllerManager,
        @NotNull PluginDescriptor descriptor, @NotNull TorrentTrackerManager torrentTrackerManager,
        @NotNull TorrentConfigurator torrentConfigurator,
        @NotNull ServerTorrentsDirectorySeeder torrentSeeder) {
    super(pagePlaces, TAB_ID, descriptor.getPluginResourcesPath("torrentSettings.jsp"), "Torrent Settings");
    myTorrentTrackerManager = torrentTrackerManager;
    myTorrentConfigurator = torrentConfigurator;
    myTorrentSeeder = torrentSeeder;/*from   w  w  w.  j  a  v  a2 s  . co  m*/
    register();

    controllerManager.registerController("/admin/torrentSettings.html", new BaseController() {
        @Override
        protected ModelAndView doHandle(@NotNull HttpServletRequest request,
                @NotNull HttpServletResponse response) throws Exception {
            if (request.getParameter("save") != null) {
                boolean transportEnabled = request.getParameter("transportEnabled") != null;
                boolean downloadEnabled = request.getParameter("downloadEnabled") != null;
                myTorrentConfigurator.setTransportEnabled(transportEnabled);
                myTorrentConfigurator.setDownloadEnabled(downloadEnabled);
                myTorrentConfigurator.setTorrentEnabled(downloadEnabled || transportEnabled);
                myTorrentConfigurator.persistConfiguration();
            }
            return new ModelAndView(
                    new RedirectView(request.getContextPath() + "/admin/admin.html?item=" + TAB_ID));
        }
    });
}

From source file:net.indialend.attendance.controller.StaffController.java

@RequestMapping("/delete")
public ModelAndView deleteStaff(String staffId) {
    ModelAndView view = new ModelAndView(new RedirectView("list"));

    if (staffId != null) {
        String[] sids = staffId.split(",");
        for (String sid : sids) {
            staffService.deleteStaff(Long.valueOf(sid));
        }//from   w ww .j  av a2  s.c  om
    }

    return view;
}