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.tracdataquality.web.controller.DataQualityAlertsController.java

/**
 * defines criterias, the number of the patients in each criteria and sets them on views as
 * alerts/* ww  w .  jav  a 2 s  .  co  m*/
 * 
 * @see org.springframework.web.servlet.mvc.AbstractController#handleRequestInternal(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse)
 */
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    //check if the user is logged in
    if (Context.getAuthenticatedUser() == null)
        return new ModelAndView(new RedirectView(request.getContextPath() + "/login.htm"));

    ModelAndView mav = new ModelAndView();
    mav.setViewName(getViewName());

    //start looking for data quality by checking each indicator
    Map<String, Integer> patientNumbers = new HashMap<String, Integer>();
    try {
        for (String key : TracDataQualityUtil.getCriteriaKeys()) {
            DataQualityByCheckTypeController checkingDataQuality = new DataQualityByCheckTypeController();

            patientNumbers.put(key, checkingDataQuality.checkTypeController(key, "").size());
        }
        mav.addObject("patientNumbers", patientNumbers);

    } catch (Exception e) {
        log.error(">>>>>TRAC>>DATA>>QUALITY>> " + e.getMessage());
        e.printStackTrace();
    }

    return mav;
}

From source file:com.googlecode.psiprobe.controllers.threads.KillThreadController.java

protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    String threadName = ServletRequestUtils.getStringParameter(request, "thread", null);

    Thread thread = null;/*from ww  w.jav  a2 s  . c o  m*/
    if (threadName != null) {
        thread = Utils.getThreadByName(threadName);
    }

    if (thread != null) {
        thread.stop();
    }

    String referer = request.getHeader("Referer");
    String redirectURL;
    if (referer != null) {
        redirectURL = referer.replaceAll(replacePattern, "");
    } else {
        redirectURL = request.getContextPath() + getViewName();
    }
    return new ModelAndView(new RedirectView(redirectURL));
}

From source file:org.openmrs.module.tracdataquality.web.controller.DownloadController.java

/**
 * @see org.springframework.web.servlet.mvc.AbstractController#handleRequestInternal(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse)
 */// w w w.  j  a v  a  2s  . c  o  m
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    if (Context.getAuthenticatedUser() == null)
        return new ModelAndView(new RedirectView(request.getContextPath() + "/login.htm"));

    //getting necessary parameters
    String programIdKey = request.getParameter("checkType");
    String valueRangeType = request.getParameter("createriaValue");

    try {
        //getting patients responding to criteria asked
        DataQualityByCheckTypeController checkingDataQuality = new DataQualityByCheckTypeController();
        List<Patient> patients = new ArrayList<Patient>();
        patients = checkingDataQuality.checkTypeController(programIdKey, valueRangeType);

        //building the fileName based on current time and the name of the indicator
        String timeNow = new SimpleDateFormat("dd_MMM_yyyy_HH_mm_ss").format(new Date());
        String fileName = ((request.getParameter("checkType") != null) ? request.getParameter("checkType") + "_"
                : "dataQualityReport_") + timeNow + ".csv";

        //download the report in csv file
        doDownload(request, response, patients, fileName,
                ContextProvider.getMessage("tracdataquality.indicator." + programIdKey));
    } catch (Exception e) {
        log.info(">>>>>TRAC>>DATA>>QUALITY>> " + e.getMessage());
        e.printStackTrace();
    }
    return null;
}

From source file:org.openmrs.module.validation.web.controller.ValidationController.java

@RequestMapping(value = "/module/validation/remove", method = RequestMethod.GET)
public ModelAndView clearList(@RequestParam("thread") Integer thread) {
    getValidationService().removeValidationThread(thread);

    return new ModelAndView(new RedirectView("list.form"));
}

From source file:org.openmrs.web.controller.maintenance.ServerLogController.java

/**
 * The onSubmit function receives the form/command object that was modified
 * by the input form and saves it to the db
 * /*w ww . j  a va 2s  .  com*/
 * @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 {
    return new ModelAndView(new RedirectView(getSuccessView()));
}

From source file:net.testdriven.psiprobe.controllers.threads.KillThreadController.java

@Override
@SuppressWarnings("deprecation")
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    String threadName = ServletRequestUtils.getStringParameter(request, "thread", null);

    Thread thread = null;//w  w w  .  j a v  a2s.  c  o  m
    if (threadName != null) {
        thread = Utils.getThreadByName(threadName);
    }

    if (thread != null) {
        thread.stop();
    }

    String referer = request.getHeader("Referer");
    String redirectURL;
    if (referer != null) {
        redirectURL = referer.replaceAll(replacePattern, "");
    } else {
        redirectURL = request.getContextPath() + getViewName();
    }
    return new ModelAndView(new RedirectView(redirectURL));
}

From source file:com.googlecode.psiprobe.controllers.system.AdviseGCController.java

protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    boolean finalization = ServletRequestUtils.getBooleanParameter(request, "fin", false);

    String referer = request.getHeader("Referer");
    String redirectURL;//from   w ww  . jav  a 2  s  . co m
    if (referer != null) {
        redirectURL = referer.replaceAll(replacePattern, "");
    } else {
        redirectURL = request.getContextPath() + getViewName();
    }
    if (finalization) {
        Runtime.getRuntime().runFinalization();
        logger.debug("Advised finalization");
    } else {
        Runtime.getRuntime().gc();
        logger.debug("Advised Garbage Collection");
    }
    logger.debug("Redirected to " + redirectURL);
    return new ModelAndView(new RedirectView(redirectURL));
}

From source file:com.googlecode.psiprobe.controllers.apps.NoSelfContextHandlerController.java

protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    try {/*from   w w  w  .j  ava 2  s  .c om*/
        if (request.getContextPath().equals(contextName)) {
            throw new IllegalStateException(
                    getMessageSourceAccessor().getMessage("probe.src.contextAction.cannotActOnSelf"));
        }

        executeAction(contextName);
    } catch (Exception e) {
        request.setAttribute("errorMessage", e.getMessage());
        logger.error(e);
        return new ModelAndView(new InternalResourceView(getViewName()));
    }
    return new ModelAndView(new RedirectView(request.getContextPath() + getViewName()
            + (isPassQueryString() ? "?" + request.getQueryString() : "")));
}

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

protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
    String action = request.getParameter("action");

    MediaFile mediaFile = mediaFileService.getMediaFile(id);

    if ("comment".equals(action)) {
        mediaFile.setComment(StringUtil.toHtml(request.getParameter("comment")));
        mediaFileService.updateMediaFile(mediaFile);
    }/*from w  w w. j  a  v  a  2  s  .c o m*/

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

From source file:org.iwethey.forums.web.user.LogoutController.java

/**
 * Remove the user name from the session to indicate that
 * the user is no longer logged in.//  w ww.ja va2 s.  c o m
 * <p>
 */
public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    HttpSession sess = request.getSession(false);
    if (sess != null) {
        sess.removeAttribute(USER_ID_ATTRIBUTE);
    }

    return new ModelAndView(new RedirectView("../main.iwt"));
}