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, boolean contextRelative) 

Source Link

Document

Create a new RedirectView with the given URL.

Usage

From source file:com.tunisbank.service.AdminControllers.java

@RequestMapping("/admin/deletegroupe")
public ModelAndView deleteGroupe(HttpServletRequest request) {

    int id = Integer.parseInt(request.getParameter("id"));
    groupesDAO.delete(id);//from w w  w  .j a  v  a  2 s .  co m
    Map model = new HashMap();
    model.put("groupes", groupesDAO.getAll());
    return new ModelAndView(new RedirectView("../admin/groupe.html", true), model);
}

From source file:org.tsm.concharto.web.changehistory.AuditableUndoController.java

@Override
protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response,
        Object command, BindException errors) throws Exception {

    UndoForm undoForm = (UndoForm) command;
    Long id = undoForm.getId();//w  w  w.ja v a 2s  . c o  m
    Integer revision = undoForm.getToRev();

    if ((id != null) && (revision != null)) {
        revertEventService.revertToRevision(this.auditableClass, revision, id);
    }
    //TODO UGH...this is a UI hack : auditables are event or event.discussion or wiki pages
    Long eventId = ServletRequestUtils.getLongParameter(request, PARAM_EVENT_ID);
    String page = ServletRequestUtils.getStringParameter(request, PARAM_PAGE);
    StringBuffer redirect = new StringBuffer(request.getContextPath()).append('/').append(getSuccessView())
            .append(".htm?id=").append(id);
    if (null != eventId) {
        redirect.append('&').append(PARAM_EVENT_ID).append('=').append(eventId);
    }
    if (!StringUtils.isEmpty(page)) {
        redirect.append('&').append(PARAM_PAGE).append('=').append(page);
    }

    //redirect back to the list
    return new ModelAndView(new RedirectView(redirect.toString(), true));

}

From source file:com.healthcit.cacure.web.controller.question.ContentElementEditController.java

/**
 * Process data entered by user/*from w  w w.ja  v a2s .  co  m*/
 * @param question
 * @param formId
 * @return
 */
@RequestMapping(method = RequestMethod.POST)
public View onSubmit(@ModelAttribute(COMMAND_NAME) ContentElement content, BindingResult result,
        SessionStatus status) {
    validateEditOperation(content);
    Long formId;

    if (content.isNew()) {
        formId = getFormId();
        qaManager.addNewFormElement(content, formId);
    } else {
        qaManager.updateFormElement(content);
        formId = content.getForm().getId();
    }
    // after question is saved - return to question listing
    return new RedirectView(Constants.QUESTION_LISTING_URI + "?formId=" + formId, true);
}

From source file:com.healthcit.cacure.web.controller.ModuleEditControllerTest.java

@Test
public void testOnSubmitForUpdate() {
    Module inputModule = createModule(1l);
    EasyMock.expect(moduleManager.updateModule(inputModule)).andReturn(createModule(inputModule.getId()));
    EasyMock.replay(moduleManager);/*from  w ww. j  a va 2 s  .co  m*/
    RedirectView expected = new RedirectView(Constants.MODULE_LISTING_URI, true);
    RedirectView actual = (RedirectView) moduleEditController.onSubmit(inputModule);

    Assert.assertNotNull(actual);
    Assert.assertEquals(expected.getUrl(), actual.getUrl());
}

From source file:org.sventon.web.ctrl.template.GoToController.java

@Override
protected ModelAndView svnHandle(final SVNConnection connection, final BaseCommand command,
        final long headRevision, final UserRepositoryContext userRepositoryContext,
        final HttpServletRequest request, final HttpServletResponse response, final BindException exception)
        throws Exception {

    final String redirectUrl;
    DirEntry.Kind kind = null;//w  w w.  j av  a2 s  .c  o m

    try {
        kind = getRepositoryService().getNodeKind(connection, command.getPath(), command.getRevisionNumber());
        logger.debug("Node kind of [" + command.getPath() + "]: " + kind);
    } catch (NoSuchRevisionException nsre) {
        logger.info(nsre.getMessage());
    }

    if (DirEntry.Kind.DIR == kind) {
        redirectUrl = command.createListUrl();
    } else if (DirEntry.Kind.FILE == kind) {
        redirectUrl = command.createShowFileUrl();
    } else if (kind == null) {
        exception.rejectValue("revision", "goto.command.invalidrevision");
        return prepareExceptionModelAndView(exception, command, getApplicationModel(command));
    } else {
        exception.rejectValue("path", "goto.command.invalidpath");
        return prepareExceptionModelAndView(exception, command, getApplicationModel(command));
    }

    // Add the redirect URL parameters
    final Map<String, String> model = new HashMap<String, String>();
    model.put("revision", command.getRevision().toString());

    logger.debug("Redirecting to: " + redirectUrl);
    return new ModelAndView(new RedirectView(redirectUrl, true), model);
}

From source file:org.sakaiproject.imagegallery.web.MultiFileUploaderController.java

public ModelAndView singleFileUpload(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    if (log.isInfoEnabled())
        log.info("req contextPath=" + request.getContextPath() + ", pathInfo=" + request.getPathInfo()
                + ", query=" + request.getQueryString() + ", URI=" + request.getRequestURI() + ", URL="
                + request.getRequestURL() + ", servlet=" + request.getServletPath());
    if (request instanceof MultipartHttpServletRequest) {
        return new ModelAndView(new RedirectView(
                "/site/AddInformationToImages?imageIds=" + storeNewImage((MultipartHttpServletRequest) request),
                true));//from   w  w w.j  a va 2  s  . c  o m
    }

    return null;
}

From source file:com.asual.summer.sample.web.TechnologyController.java

@RequestMapping(value = "/{value}", method = RequestMethod.DELETE)
public ModelAndView remove(@PathVariable("value") String value) {
    Technology technology = Technology.find(value);
    if (technology != null) {
        technology.remove();/*  w ww . java  2s .  co  m*/
    }
    return new ModelAndView(new RedirectView("/technology", true));
}

From source file:org.jasig.cas.services.web.RegisteredServiceSimpleFormController.java

/**
 * Adds the service to the ServiceRegistry via the ServiceRegistryManager.
 * // w w  w  . ja va2 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 final ModelAndView onSubmit(final HttpServletRequest request, final HttpServletResponse response,
        final Object command, final BindException errors) throws Exception {
    final RegisteredService service = (RegisteredService) command;

    this.servicesManager.save(service);
    logger.info("Saved changes to service " + service.getId());

    final ModelAndView modelAndView = new ModelAndView(
            new RedirectView("/services/manage.html#" + service.getId(), true));
    modelAndView.addObject("action", "add");
    modelAndView.addObject("id", service.getId());

    return modelAndView;
}

From source file:com.tristanchanson.vpm.user.UserInterceptor.java

private boolean requireSignIn(HttpServletRequest request, HttpServletResponse response) throws Exception {
    new RedirectView("/", true).render(null, request, response);
    return false;
}

From source file:com.cloudfoundry.samples.spring.user.UserInterceptor.java

private boolean requireSignIn(HttpServletRequest request, HttpServletResponse response) throws Exception {
    new RedirectView("/signin", true).render(null, request, response);
    return false;
}