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:fr.hoteia.qalingo.web.mvc.controller.shipping.ShippingController.java

@RequestMapping(value = BoUrls.SHIPPING_EDIT_URL, method = RequestMethod.POST)
public ModelAndView submitShippingEdit(final HttpServletRequest request, final Model model,
        @Valid ShippingForm shippingForm, BindingResult result) throws Exception {

    final String currentShippingId = request.getParameter(RequestConstants.REQUEST_PARAMETER_SHIPPING_CODE);
    final Shipping shipping = shippingService.getShippingByCode(currentShippingId);

    if (result.hasErrors()) {
        return shippingEdit(request, model);
    }/*from ww  w  .j a  v a2s  . com*/

    // UPDATE SHIPPING
    //      webBackofficeService.updateShipping(shipping, shippingForm);

    final String urlRedirect = backofficeUrlService.buildShippingDetailsUrl(currentShippingId);
    return new ModelAndView(new RedirectView(urlRedirect));
}

From source file:fr.hoteia.qalingo.web.mvc.controller.enginesetting.EngineSettingController.java

@RequestMapping(value = "/engine-setting-details.html*", method = RequestMethod.GET)
public ModelAndView engineSettingDetails(final HttpServletRequest request, final HttpServletResponse response)
        throws Exception {
    ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request),
            "engine-setting/engine-setting-details");

    final String engineSettingId = request.getParameter(RequestConstants.REQUEST_PARAMETER_ENGINE_SETTING_ID);
    if (StringUtils.isNotEmpty(engineSettingId)) {
        EngineSetting engineSetting = engineSettingService.getEngineSettingById(engineSettingId);
        if (engineSetting != null) {
            final Localization currentLocalization = requestUtil.getCurrentLocalization(request);
            final Locale locale = currentLocalization.getLocale();

            initLinks(request, modelAndView, locale, engineSetting);

            modelAndView.addObject("engineSettingDetails",
                    viewBeanFactory.buildEngineSettingDetailsViewBean(requestUtil.getRequestData(request)));

            modelAndView.addObject("engineSetting", viewBeanFactory
                    .buildEngineSettingViewBean(requestUtil.getRequestData(request), engineSetting));
        } else {/*from   w  w  w  .ja v a 2  s . c om*/
            final String url = requestUtil.getLastRequestUrl(request);
            return new ModelAndView(new RedirectView(url));
        }
    } else {
        final String url = requestUtil.getLastRequestUrl(request);
        return new ModelAndView(new RedirectView(url));
    }

    formFactory.buildEngineSettingQuickSearchForm(request, modelAndView);

    return modelAndView;
}

From source file:ru.org.linux.comment.EditCommentController.java

/**
 *  ?.// www  .  j  av a 2  s.co  m
 *
 * @param commentRequest WEB-, ?? 
 * @param errors            ? 
 * @param request         ?  web-
 * @return  web-
 * @throws Exception
 */
@RequestMapping(value = "/edit_comment", method = RequestMethod.POST)
@CSRFNoAuto
public ModelAndView editCommentPostHandler(@ModelAttribute("edit") @Valid CommentRequest commentRequest,
        Errors errors, HttpServletRequest request, @ModelAttribute("ipBlockInfo") IPBlockInfo ipBlockInfo)
        throws Exception {
    Map<String, Object> formParams = new HashMap<>();

    User user = commentService.getCommentUser(commentRequest, request, errors);

    commentService.checkPostData(commentRequest, user, ipBlockInfo, request, errors);
    commentService.prepareReplyto(commentRequest, formParams, request);

    String msg = commentService.getCommentBody(commentRequest, user, errors);
    Comment comment = commentService.getComment(commentRequest, user, request);

    if (commentRequest.getTopic() != null) {
        formParams.put("postscoreInfo",
                TopicPermissionService.getPostScoreInfo(commentRequest.getTopic().getPostScore()));
        topicPermissionService.checkCommentsAllowed(commentRequest.getTopic(), user, errors);
        formParams.put("comment",
                commentPrepareService.prepareCommentForEdit(comment, msg, request.isSecure()));
    }

    boolean editable = topicPermissionService.isCommentsEditingAllowed(commentRequest.getOriginal(),
            commentRequest.getTopic(), request);

    if (!editable) {
        throw new AccessViolationException(
                " ?     ? ??");
    }

    if (commentRequest.isPreviewMode() || errors.hasErrors() && comment == null) {
        ModelAndView modelAndView = new ModelAndView("edit_comment", formParams);
        modelAndView.addObject("ipBlockInfo", ipBlockInfo);
        return modelAndView;
    }

    String originalMessageText = msgbaseDao.getMessageText(commentRequest.getOriginal().getId()).getText();

    commentService.edit(commentRequest.getOriginal(), comment, msg, request.getRemoteAddr(),
            request.getHeader("X-Forwarded-For"));
    searchQueueSender.updateComment(commentRequest.getOriginal().getId());

    commentService.addEditHistoryItem(user, commentRequest.getOriginal(), originalMessageText, comment, msg);
    commentService.updateLatestEditorInfo(user, commentRequest.getOriginal(), comment);

    String returnUrl = "/jump-message.jsp?msgid=" + commentRequest.getTopic().getId() + "&cid="
            + commentRequest.getOriginal().getId();

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

From source file:de.otto.mongodb.profiler.web.DatabaseController.java

@RequestMapping(value = "/{name:.+}/control", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, params = "action=remove")
public View removeDatabase(@PathVariable("connectionId") final String connectionId,
        @PathVariable("name") final String databaseName, final UriComponentsBuilder uriComponentsBuilder)
        throws ResourceNotFoundException {

    final ProfiledDatabase database = requireDatabase(connectionId, databaseName);
    getProfilerService().removeDatabase(database);

    final String uri = uriComponentsBuilder.path("/connections/{id}").buildAndExpand(connectionId)
            .toUriString();// w  ww  .  j  a v  a  2  s.  co m

    return new RedirectView(uri);
}

From source file:fr.hoteia.qalingo.web.mvc.controller.customer.CustomerAddressController.java

@RequestMapping(value = FoUrls.PERSONAL_EDIT_ADDRESS_URL, method = RequestMethod.GET)
public ModelAndView displayCustomerEditAddress(final HttpServletRequest request, final Model model,
        @ModelAttribute("customerAddressForm") CustomerAddressForm customerAddressForm) throws Exception {
    ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request),
            FoUrls.PERSONAL_EDIT_ADDRESS.getVelocityPage());

    final Customer currentCustomer = requestUtil.getCurrentCustomer(request);

    final CustomerAddressListViewBean customerAdressesViewBean = viewBeanFactory
            .buildCustomerAddressListViewBean(requestUtil.getRequestData(request), currentCustomer);
    model.addAttribute("customerAdresses", customerAdressesViewBean);

    String customerAddressId = request.getParameter(RequestConstants.REQUEST_PARAMETER_CUSTOMER_ADDRESS_ID);
    if (StringUtils.isEmpty(customerAddressId)) {
        customerAddressId = customerAddressForm.getIdOrGuid();
    }/*from  ww w.  j a  v  a 2s.c  o m*/

    CustomerAddress customerAddress = null;
    try {
        final Customer customer = requestUtil.getCurrentCustomer(request);
        customerAddress = customer.getAddress(new Long(customerAddressId));

    } catch (Exception e) {
        LOG.error("Error with the address to edit, customerAddressId:" + customerAddressId, e);
        final String urlRedirect = urlService.generateUrl(FoUrls.PERSONAL_ADDRESS_LIST,
                requestUtil.getRequestData(request));
        return new ModelAndView(new RedirectView(urlRedirect));
    }

    // SANITY CHECK : wrong address id for this customer
    if (customerAddress == null) {
        final String urlRedirect = urlService.generateUrl(FoUrls.PERSONAL_ADDRESS_LIST,
                requestUtil.getRequestData(request));
        return new ModelAndView(new RedirectView(urlRedirect));
    }

    if (customerAddressForm == null || customerAddressForm.equals(new CustomerAddressForm())) {
        customerAddressForm = formFactory.buildCustomerAddressForm(request, customerAddress);
        model.addAttribute("customerAddressForm", customerAddressForm);
    }

    return modelAndView;
}