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:org.openmrs.module.metadatasharing.web.utils.WebUtils.java

/**
 * Redirects to the given URL.//from www .  jav a 2 s .c o  m
 * 
 * @param url the URL to redirect
 * @param args the URL arguments. E.g. "group=123&id=2"
 * @param exposeModelAttributes the boolean stating if the model attributes should be exposed in
 *            the redirect URL
 * @return ModelAndView which redirects to the given page
 */
public static ModelAndView redirect(String url, String args, boolean exposeModelAttributes) {
    url = url + ".form";
    if (args != null) {
        url = url + "?" + args;
    }
    RedirectView redirect = new RedirectView(url, true);
    redirect.setExposeModelAttributes(exposeModelAttributes);
    return new ModelAndView(redirect);
}

From source file:org.duracloud.account.app.controller.UserController.java

protected static RedirectView formatUserRedirect(String username) {
    String redirect = formatUserUrl(username);
    RedirectView view = new RedirectView(redirect, true);
    view.setExposeModelAttributes(false);
    return view;/*  w  w  w  .j  av  a  2  s.  c  o m*/
}

From source file:org.duracloud.account.app.controller.AbstractController.java

protected ModelAndView createRedirectMav(String url) {
    RedirectView view = new RedirectView(url, true);
    view.setExposeModelAttributes(false);
    return new ModelAndView(view);
}

From source file:edu.mayo.xsltserver.controller.AdminController.java

/**
 * delete.//from  ww w.ja  va 2s  .com
 *
 * @param fileName the file name
 * @return the redirect view
 * @throws Exception the exception
 */
@RequestMapping(value = "/admin/file/{fileName}", method = RequestMethod.DELETE)
public RedirectView delete(@PathVariable String fileName) throws Exception {

    this.fileService.delete(fileName);

    RedirectView view = new RedirectView("../../admin");
    view.setExposeModelAttributes(false);

    return view;
}

From source file:edu.mayo.xsltserver.controller.AdminController.java

/**
 * upload.//from w w  w  .j  a v a  2s  .c o  m
 *
 * @param request the request
 * @param response the response
 * @return the redirect view
 * @throws Exception the exception
 */
@RequestMapping(value = "/admin/files", method = RequestMethod.POST)
public RedirectView upload(HttpServletRequest request, HttpServletResponse response) throws Exception {

    MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
    MultipartFile multipartFile = multipartRequest.getFile("file");

    String fileName = multipartFile.getOriginalFilename();
    fileService.store(fileName, multipartFile.getBytes());

    RedirectView view = new RedirectView("../admin");
    view.setExposeModelAttributes(false);

    return view;
}

From source file:ru.org.linux.tracker.TrackerController.java

@RequestMapping("/tracker.jsp")
public View trackerOldUrl(@RequestParam(value = "filter", defaultValue = "all") String filterAction)
        throws UnsupportedEncodingException {
    RedirectView redirectView = new RedirectView("/tracker/");

    redirectView.setExposeModelAttributes(false);

    if (filterValues.contains(filterAction) && !filterAction.equals("all")) {
        redirectView.setUrl("/tracker/?filter=" + URLEncoder.encode(filterAction, "UTF-8"));
    }//  w  w  w.j a v a 2 s.c om

    return redirectView;
}

From source file:org.duracloud.account.app.controller.AbstractAccountController.java

/**
 * /*from  ww w .j  av  a 2 s.  co m*/
 * @param accountId
 * @param suffix
 * @return
 */
protected View createAccountRedirectView(Long accountId, String suffix) {
    String url = MessageFormat.format("{0}{1}{2}", ACCOUNTS_PATH,
            ACCOUNT_PATH.replace("{accountId}", String.valueOf(accountId)), suffix);

    RedirectView redirectView = new RedirectView(url, true);
    redirectView.setExposeModelAttributes(false);

    return redirectView;
}

From source file:org.codeqinvest.web.project.CreateProjectController.java

/**
 * This methods handles the submitted form for creating a new project.
 *///from  w  w w  . j  a  v  a 2  s  . c  om
@RequestMapping(value = "/create", method = RequestMethod.POST)
ModelAndView create(@ModelAttribute Project project, BindingResult bindingResult,
        @ModelAttribute("retrievedSonarProjectsAsJson") String sonarProjects, Model model) {

    projectConnectionsValidator.validate(project, bindingResult);
    if (bindingResult.hasErrors()) {
        log.info("Rejected creation of project due {} validation errors", bindingResult.getErrorCount());
        if (log.isDebugEnabled()) {
            for (FieldError fieldError : bindingResult.getFieldErrors()) {
                log.debug("Field {} has following error: {}", fieldError.getField(), fieldError.getCode());
            }
        }
        addDeserializedSonarProjectsToModel(sonarProjects, model);
        model.addAttribute("fieldErrors", bindingResult.getFieldErrors());
        return new ModelAndView("createProject");
    }

    // this little hack is necessary until a better way for binding the value from the form is found
    CodeChangeSettings codeChangeSettings = project.getCodeChangeSettings();
    if (codeChangeSettings.getMethod() == SupportedCodeChangeProbabilityMethod.COMMIT_BASED.getId()) {
        codeChangeSettings.setNumberOfCommits(codeChangeSettings.getDays());
        codeChangeSettings.setDays(null);
    }

    Project addedProject = projectRepository.save(project);
    analyzerScheduler.scheduleAnalyzer(addedProject);
    log.info("Created project {} and scheduled its quality analysis", project.getName());

    RedirectView redirect = new RedirectView("/projects/" + addedProject.getId());
    redirect.setExposeModelAttributes(false);
    return new ModelAndView(redirect);
}

From source file:com.ari.controller.catalog.CategoryController.java

@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    ModelAndView model = super.handleRequest(request, response);

    Category category = (Category) model.getModel().get("category");

    if (request.getRequestURI().equals("/")) {
        category = (Category) model.getModelMap().get("category");
        String url = category.getChildCategories().get(0).getUrl();
        //  ./*from  w w w .  j a va  2 s  . co m*/
        RedirectView rv = new RedirectView(url);
        rv.setExposeModelAttributes(true);

        return new ModelAndView(rv);
    }

    //?  ? category .
    //TODO  .
    if (false == request.getParameterMap().containsKey("facetField")) {
        //            List<SortOption> sortOptions = ((ExCategoryImpl) model.getModelMap().get(CATEGORY_ATTRIBUTE_NAME)).getSortOptions();
        //            for(SortOption sortOption : sortOptions){
        //                String sortCondition = sortOption.getSortCondition();
        //                sortOption.setLink(addSortLink(sortOption));
        //            }
    }

    //? ?   
    CategoryAttribute categoryType = category.getCategoryAttributesMap().get("CategoryType");
    if (categoryType != null) {
        String categoryTypeValue = categoryType.getValue();

        if (categoryTypeValue.equals("main") && null != request.getParameter("page")) {
            model.setViewName("/ari/layout/partials/productList");
        }
    }

    return model;
}

From source file:net.longfalcon.web.BaseController.java

protected RedirectView safeRedirect(String url) {
    RedirectView rv = new RedirectView(url, true);
    rv.setExposeModelAttributes(false);
    return rv;//from  w  ww  . j  av  a 2  s .  c  o  m
}