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

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

Introduction

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

Prototype

public void setExposeModelAttributes(final boolean exposeModelAttributes) 

Source Link

Document

Set the exposeModelAttributes flag which denotes whether or not model attributes should be exposed as HTTP query parameters.

Usage

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);/*  w ww .j ava  2  s .c  o m*/
}

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

@RequestMapping(method = RequestMethod.GET)
public ModelAndView showReportForm(
        ////from   w  ww. ja  v a  2s. c  o m
        @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;
}