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

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

Introduction

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

Prototype

public void setPropagateQueryParams(boolean propagateQueryParams) 

Source Link

Document

When set to true the query string of the current URL is appended and thus propagated through to the redirected URL.

Usage

From source file:example.springdata.web.users.web.UserController.java

/**
 * Registers a new {@link User} for the data provided by the given {@link UserForm}. Note, how an interface is used to
 * bind request parameters./* ww  w.j  av  a  2s .c  o m*/
 * 
 * @param form the request data bound to the {@link UserForm} instance.
 * @param binding the result of the binding operation.
 * @param model the Spring MVC {@link Model}.
 * @return
 */
@RequestMapping(method = RequestMethod.POST)
public Object register(UserForm userForm, BindingResult binding, Model model) {

    userForm.validate(binding, userManagement);

    if (binding.hasErrors()) {
        return "users";
    }

    userManagement.register(new Username(userForm.getUsername()), Password.raw(userForm.getPassword()));

    RedirectView redirectView = new RedirectView("redirect:/users");
    redirectView.setPropagateQueryParams(true);

    return redirectView;
}

From source file:de.interseroh.report.controller.ReportController.java

private void showReportForm(@PathVariable("reportName") String reportName,
        @ModelAttribute("parameterForm") ParameterForm form, ModelAndView modelAndView) {
    RedirectView redirectView = new RedirectView();
    redirectView.setUrl("/reports/{reportName}");
    redirectView.setContextRelative(true);
    redirectView.setPropagateQueryParams(false);
    redirectView.setExposeModelAttributes(true);
    modelAndView.addAllObjects(new ParameterValueMapBuilder().build(form));
    modelAndView.addObject("reportName", reportName);
    modelAndView.setView(redirectView);/*from ww  w  .ja va2s. c  o m*/
}

From source file:de.interseroh.report.controller.ReportController.java

@RequestMapping(method = RequestMethod.GET)
public ModelAndView showReportForm(
        ////  w  w  w. j av  a 2s  .com
        @ModelAttribute ParameterForm parameterForm, //
        @RequestParam MultiValueMap<String, String> requestParams,
        @PathVariable("reportName") String reportName, BindingResult errors) throws BirtReportException {

    logger.debug("executing show report for " + reportName);

    checkPermisionFor(reportName);

    ModelAndView modelAndView = new ModelAndView();

    parameterFormBinder.bind(parameterForm, requestParams, errors);
    parameterFormConverter.convert(parameterForm, errors);

    if (parameterForm.isValid()) {
        Pagination pagination = reportService.getPageInfos(reportName, parameterForm);

        // TODO reportPage
        // if (reportPage.getCurrentPageNumber() > reportPage
        // .getPageNumbers()) {
        // throw new BirtReportException(String.format(
        // "For this report: %s no more pages available",
        // reportName));
        // }
        modelAndView.addObject("pagination", pagination);
        modelAndView.setViewName("/report");
        injectReportUri(parameterForm, modelAndView, reportName);
        configSetter.setVersion(modelAndView);
        configSetter.setBranding(modelAndView);
    } else {
        // show parameters
        RedirectView redirectView = new RedirectView();
        redirectView.setUrl("/reports/{reportName}/params");
        redirectView.setContextRelative(true);
        redirectView.setPropagateQueryParams(false);
        redirectView.setExposeModelAttributes(true);
        modelAndView.setView(redirectView);
        modelAndView.addAllObjects(new ParameterValueMapBuilder().build(parameterForm));
    }

    parameterFormFormatter.format(parameterForm);
    modelAndView.addObject("reportName", reportName);

    return modelAndView;
}